import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "next", long, "cost");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, m, R;
    scan(n, m, R);
    auto r = aryread.sort.array();
    auto route = new Pair[][](n, 0);
    foreach (_; iota(m))
    {
        long a, b, c;
        scan(a, b, c);
        route[a - 1] ~= Pair(b - 1, c);
        route[b - 1] ~= Pair(a - 1, c);
    }

    auto mincost = new long[][](n, n);
    foreach (i; iota(n))
    {
        mincost[i][] = INF;
        mincost[i][i] = 0;
    }

    foreach (i; iota(n))
    {
        foreach (e; route[i])
        {
            mincost[i][e.next] = e.cost;
        }
    }

    foreach (k; iota(n))
    {
        foreach (i; iota(n))
        {
            foreach (j; iota(n))
            {
                if (mincost[i][j] > mincost[i][k] + mincost[k][j])
                    mincost[i][j] = mincost[i][k] + mincost[k][j];
            }
        }
    }

    long ans = INF;
    while (r.nextPermutation())
    {
        long tmp;
        foreach (i; iota(R - 1))
        {
            tmp += mincost[r[i] - 1][r[i + 1] - 1];
        }
        ans = min(ans, tmp);
    }
    ans.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
