N,M,R=gets.split.map(&:to_i)
r=gets.split.map(&:to_i)

len=(0..N).map{[1e9]*(N+1)}

M.times{
  a,b,c=gets.split.map(&:to_i)
  len[a][b]=len[b][a]=c
}

(1..N).each{|k|(1..N).each{|i|(1..N).each{|j|
  len[i][j] = [len[i][j],len[i][k]+len[k][j]].min
}}}

p r.permutation.map{|a|
  a.each_cons(2).inject(0){|s,(r1,r2)|s+len[r1][r2]}
}.min
