import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable inf = 10^^9;

void main() {
    int N, M, R;
    int[] r;

    scan(N, M, R);
    r = readln.split.to!(int[]);
    r[] -= 1;

    int[][] c = new int[][](N, N);
    fillAll(c, inf);
    foreach (i ; 0 .. N) c[i][i] = 0;

    foreach (i ; 0 .. M) {
        int ai, bi, ci;
        scan(ai, bi, ci);
        ai--; bi--;
        c[ai][bi] = ci;
        c[bi][ai] = ci;
    }

    foreach (k ; 0 .. N) {
        foreach (i ; 0 .. N) {
            foreach (j ; 0 .. N) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    debug {
        writefln("%(%(%s %)\n%)", c);
    }

    int ans = 10^^9;

    foreach (rs ; r.permutations) {
        debug {
            writeln(rs);
        }
        int tmp;
        foreach (i ; 0 .. R - 1) {
            tmp += c[rs[i]][rs[i + 1]];
        }

        ans = min(ans, tmp);
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}