import std.stdio, std.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range, std.functional;
 
void main() {
    auto tmp = readln.split.to!(ulong[]);
    auto N = tmp[0];
    auto M = tmp[1];
    auto R = tmp[2];
    auto r = readln.split.to!(ulong[]);
    ulong[][] distance = new ulong[][](N,N);
    foreach (i; 0..N) {
        foreach (j; 0..N) {
            distance[i][j] = ulong.max / 2;
        }
    }
    foreach (i; 0..M) {
        tmp = readln.split.to!(ulong[]);
        distance[tmp[0]-1][tmp[1]-1] = tmp[2];
        distance[tmp[1]-1][tmp[0]-1] = tmp[2];
    }
    foreach (k; 0..N) {
        foreach (i; 0..N) {
            foreach (j; 0..N) {
                distance[i][j] = min(distance[i][j], distance[i][k] + distance[k][j]);
            }
        }
    }
    auto perm = sort(r);
    ulong res = ulong.max;
    do {
        res = min(res, iota(R-1).map!(i => distance[perm[i]-1][perm[i+1]-1]).sum);
    } while (nextPermutation(perm));
    writeln(res);
}
