local n,m,r=io.read("n","n","n")
local town={}
for i=1,r do
    town[i]=io.read("n")
end

local disttable={}
local INF=10^12
for i=1,n do
    disttable[i]={}
    for j=1,n do
        disttable[i][j]=(i==j and 0 or INF)
    end
end

for i=1,m do
    local a,b,c=io.read("n","n","n")
    disttable[a][b]=c
    disttable[b][a]=c
end

for k=1,n do
    for i=1,n do
        for j=1,n do
            disttable[i][j]=math.min(disttable[i][j],disttable[i][k]+disttable[k][j])
        end
    end
end

local totaldist=0
for i=1,r-1 do
    local mindist=INF
    local r1=town[i]
    for j=i+1,r do
        local r2=town[j]
        mindist=math.min(mindist,disttable[r1][r2])
    end
    totaldist=totaldist+mindist
end
print(totaldist)