import std.algorithm, std.conv, std.range, std.stdio, std.string;

alias graph = Graph!(int, size_t);

void main()
{
  auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1], r = rd1[2];
  auto rs = readln.split.to!(size_t[]).map!"a-1".array;
  rs.sort();

  auto g = new int[][](n, n);
  foreach (i; 0..n) {
    g[i][] = graph.inf;
    g[i][i] = 0;
  }

  foreach (_; 0..m) {
    auto rd2 = readln.split, a = rd2[0].to!size_t-1, b = rd2[1].to!size_t-1, c = rd2[2].to!int;
    g[a][b] = g[b][a] = c;
  }

  auto d = graph.floydWarshal(g);

  auto ans = int.max;
  do {
    auto t = 0;
    foreach (i; 0..r-1) t += d[rs[i]][rs[i+1]];
    ans = min(ans, t);
  } while (rs.nextPermutation);

  writeln(ans);
}

template Graph(Wt, Node, Wt _inf = 10 ^^ 9, Node _sent = Node.max)
{
  import std.algorithm, std.array, std.conv;

  const inf = _inf, sent = _sent;

  Wt[][] floydWarshal(Wt[][] g)
  {
    Wt[][] dist;
    Node[][] inter;
    floydWarshal(g, dist, inter);
    return dist;
  }

  void floydWarshal(Wt[][] g, out Wt[][] dist, out Node[][] inter)
  {
    auto n = g.length;
    dist = g.map!(i => i.dup).array;

    inter = new Node[][](n, n);
    foreach (i; 0..n) inter[i][] = sent;

    foreach (k; 0..n)
      foreach (i; 0..n)
        foreach (j; 0..n)
          if (dist[i][j] > dist[i][k] + dist[k][j]) {
            dist[i][j] = dist[i][k] + dist[k][j];
            inter[i][j] = k.to!Node;
          }
  }
}
