--http://www.nct9.ne.jp/m_hiroi/light/lua04.html

function member(x, ary)
    for i = 1, #ary do
        if x == ary[i] then return true end
    end
    return false
end
  
function permutations(fn, n, m, a)
    if #a == m then
       fn(a)
    else
        for x = 1, n do
            if not member(x, a) then
                table.insert(a, x)
                permutations(fn, n, m, a)
                table.remove(a)
            end
        end
    end
end

----------

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^13
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 distsum={}

permutations(
    function(list)
        local dist=0
        for i=1,#list-1 do
            local cur=town[list[i]]
            local nxt=town[list[i+1]]
            dist=dist+disttable[cur][nxt]
        end
        table.insert(distsum,dist)
    end, 
    r, 
    r, 
    {}
)

local totaldist=10^13
for i=1,#distsum do
    totaldist=math.min(totaldist,distsum[i])
end
print(totaldist)