#coding=UTF-8

def search(jun):
    global ans
    global R
    global Kost
    tmpans=0
    if len(jun)==R:
        mae=jun[0]
        for idx in range(1,R,1):
            ba=jun[idx]
            tmpans += Kost[r[mae]][r[ba]]
            mae=ba

        if ans==None or tmpans<ans:
            ans=tmpans
    else:
        for me in range(0,R,1):
            if not (me in jun):
                search(jun+[me])

mozir=input()
hyo=mozir.split(' ')
N=int(hyo[0])
M=int(hyo[1])
R=int(hyo[2])

mozir=input()
hyo=mozir.split(' ')
r=[(int(mono)-1) for mono in hyo]

Kost=[]
for idx in range(0,N,1):
    Kost.append([None]*N)

for idx in range(0,N,1):
    Kost[idx][idx]=0


for idx in range(0,M,1):
    mozir=input()
    hyo=mozir.split(' ')
    A=int(hyo[0])-1
    B=int(hyo[1])-1
    C=int(hyo[2])

    Kost[A][B]=C
    Kost[B][A]=C

changed=True
while changed:
    changed=False
    for idx in range(0,N,1):
        for idt in range(0,N,1):
            if bool(Kost[idx][idt]) == False:
                continue
            else:
                zen=Kost[idx][idt]
                for idy in range(0,N,1):
                    ato=Kost[idt][idy]
                    if ato == None:
                        continue
                    
                    tmpKost=zen+ato
                    if Kost[idx][idy]==None or Kost[idx][idy]>tmpKost:
                        Kost[idx][idy]=tmpKost
                        changed=True

#for gyo in Kost:
#    print(gyo)

ans=None
search([])
print(ans)
