using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    int N, M, R;
    int[] r;
    int[] A, B;
    long[] C;
    void Solve() {
        //input
        N = io.Int;
        M = io.Int;
        R = io.Int;
        r = new int[R];
        for (int i = 0; i < R; ++i)
            r[i] = io.Int;
        A = new int[M];
        B = new int[M];
        C = new long[M];
        for (int i = 0; i < M; ++i) {
            A[i] = io.Int;
            B[i] = io.Int;
            C[i] = io.Long;
        }
        //cal
        var warshal = new WarshallFloyd();
        warshal.Init(N);
        warshal.AddPath(A, B, C);
        warshal.Run();
        long ans = long.MaxValue;
        foreach (var v in enuPermutation(r)) {
            var tmp = 0L;
            for (int i = 1; i < v.Length; ++i) {
                tmp += warshal.G[v[i - 1], v[i]];
            }
            ans = Math.Min(ans, tmp);
        }
        //res
        Console.WriteLine(ans);
    }
    public IEnumerable<int[]> enuPermutation(int[] Arr, int Use = -1) {
        Use = (Use != -1) ? Use : Arr.Length;
        if (Use == 0 || Arr.Length < Use) yield break;
        var s = new Stack<List<int>>();
        for (int i = Arr.Length - 1; i >= 0; i--)
            s.Push(new List<int>() { i });
        while (s.Count > 0) {
            var cur = s.Pop();
            if (cur.Count == Use) {
                var ret = new List<int>(); cur.ForEach(X => ret.Add(Arr[X]));
                yield return ret.ToArray();
            } else
                for (int i = 0; i < Arr.Length; ++i)
                    if (!cur.Contains(i))
                        s.Push(new List<int>(cur) { i });
        }
    }


    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}

class WarshallFloyd {
    private long INF = (long)1e15;
    private int E;
    public long[,] G;
    public void Init(int n) {
        E = n + 1;
        G = new long[E, E];
        for (int i = 0; i < E; ++i)
            for (int j = 0; j < E; ++j)
                G[i, j] = INF;
        for (int i = 0; i < E; ++i)
            G[i, i] = 0;
    }
    public void AddPath(int f, int t, long c) {
        G[f, t] = c;
        G[t, f] = c;
    }
    public void AddPath(int[] f, int[] t) {
        for (int i = 0; i < f.Length; ++i)
            AddPath(f[i], t[i], 1);
    }
    public void AddPath(int[] f, int[] t, long[] c) {
        for (int i = 0; i < f.Length; ++i)
            AddPath(f[i], t[i], c[i]);
    }
    public void Run() {
        G = MinCostArr();
    }
    public long[,] MinCostArr() {
        for (int i = 0; i < E; ++i)
            for (int j = 0; j < E; ++j)
                for (int k = 0; k < E; ++k)
                    G[j, k] = Math.Min(G[j, k], G[j, i] + G[i, k]);
        return G;
    }
}

class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 18892