import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    int N, M, R; readf("%d %d %d\n", &N, &M, &R);
    auto Rs = readln.chomp.split(" ").map!((a) => a.to!int - 1).array;
    auto G = new int[][](N, N);
    foreach (ref L; G) L[] = int.max / 8;
    foreach (i; 0 .. M) {
        int a, b, c; readf("%d %d %d\n", &a, &b, &c);
        a--; b--;
        G[a][b] = G[b][a] = c;
    }
    foreach (k; 0 .. N) {
        foreach (i; 0 .. N) {
            foreach (j; 0 .. N) {
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }

    sort(Rs);
    long ans = long.max / 8;
    do {
        long cost = 0;
        foreach (i; 0 .. (R - 1)) {
            int from = Rs[i];
            int to = Rs[i + 1];
            cost += G[from][to];
        }
        ans = min(ans, cost);
    } while (Rs.nextPermutation);
    writeln(ans);
}
