local mmi, mma = math.min, math.max
local mfl, mce = math.floor, math.ceil
local n, m, r = io.read("*n", "*n", "*n")
local t = {}
for i = 1, r do
  t[i] = io.read("*n")
end
local inf = 1000000007 * 1000
local len = {}
for i = 1, n do
  len[i] = {}
  for j = 1, n do
    len[i][j] = i == j and 0 or inf
  end
end
for i = 1, m do
  local a, b, c = io.read("*n", "*n", "*n")
  len[a][b], len[b][a] = c, c
end
for k = 1, n do
  for i = 1, n do
    for j = 1, n do
      len[i][j] = mmi(len[i][j], len[i][k] + len[k][j])
    end
  end
end

local function getpattern(n, patall, idx)
  local used = {}
  local retary = {}
  local div = patall
  for i = 1, n do used[i] = false end
  for i = n, 1, -1 do
    div = mfl(div / i)
    local v_idx = mfl(idx / div)
    idx = idx % div
    local tmp_idx = 0
    for j = 1, n do
      if not used[j] then
        if tmp_idx == v_idx then
          table.insert(retary, j)
          used[j] = true
          break
        else
          tmp_idx = tmp_idx + 1
        end
      end
    end
  end
  return retary
end
local tot = 1
for i = 1, r do
  tot = tot * i
end
local ret = inf
for i = 0, tot - 1 do
  local pat = getpattern(r, tot, i)
  local z = 0
  for i = 1, r - 1 do
    z = z + len[t[pat[i]]][t[pat[i + 1]]]
  end
  if z < ret then ret = z end
end
print(ret)
