import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

enum INF(T) = T.max / 3;

bool chmin(t)(ref t a, t b) {
  if (b < a) {
    a = b;
    return true;
  } else {
    return false;
  }
}

void main() {
  int[] NMR = readln.chomp.split.to!(int[]);
  int N = NMR[0],
      M = NMR[1],
      R = NMR[2];
  int[] rs = readln.chomp.split.to!(int[]);
  int[201][201] dp;

  foreach (i, ref col; dp) {
    foreach (j, ref e; col) {
      if (i == j) {
        e = 0;
      } else {
        e = INF!int;
      }
    }
  }

  foreach (_; 0..M) {
    int[] ABC = readln.chomp.split.to!(int[]);
    int A = ABC[0],
        B = ABC[1],
        C = ABC[2];
    A--;
    B--;

    if (dp[A][B] > 0) {
      dp[A][B] = dp[B][A] = C;
    }
  }

  foreach (i; 0..N) {
    foreach (j; 0..N) {
      foreach (k; 0..N) {
        chmin(dp[j][k], dp[j][i] + dp[i][k]);
      }
    }
  }

  int ans = int.max;

  foreach (r; rs.permutations) {
    int t;
    foreach (i; 0..R-1) {
      t += dp[r[i] - 1][r[i+1] - 1];
    }
    chmin(ans, t);
  }

  writeln(ans);
}