using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();
            var input = cin.SplitRead();
            int N = input[0];
            int M = input[1];
            int R = input[2];
            var r = cin.SplitRead();
            var d = new long[N, N];
            for(var i = 0; i < N; i++)
            {
                for(var j = 0; j < N; j++)
                {
                    d[i, j] = i == j ? 0 : SINF;
                }
            }

            for(var i = 0; i < M; i++)
            {
                var e = cin.SplitRead();
                int A = e[0] - 1;
                int B = e[1] - 1;
                int C = e[2];

                d[A, B] = C;
                d[B, A] = C;
            }

            Warshall_floyd(N, d);

            var list = new List<int>();
            for(var i = 0; i < R; i++)
            {
                list.Add(i);
            }

            long ans = SINF;
            var per = Permutation<int>.All(list);
            foreach(var p in per)
            {
                int[] order = new int[R];
                long dist = 0;
                for(var i = 0; i < R; i++)
                {
                    order[p[i]] = r[i] - 1;
                }

                for(var i = 0; i < R - 1; i++)
                {
                    dist += d[order[i], order[i + 1]];
                }

                ans = Min(ans, dist);
            }

            Console.WriteLine(ans);

           
            //Console.Out.Flush();
        }

        static public void Warshall_floyd(int n, long[,] dist)
        {
            for (var k = 0; k < n; k++)
            {
                for (var i = 0; i < n; i++)
                {
                    for (var j = 0; j < n; j++)
                    {
                        dist[i, j] = Min(dist[i, j], dist[i, k] + dist[k, j]);
                    }
                }
            }
        }

    }
    static class Permutation<T>
    {
        private static void Search(List<T[]> perms, Stack<T> stack, T[] a)
        {
            int N = a.Length;
            if (N == 0)
            {
                perms.Add(stack.Reverse().ToArray());
            }
            else
            {
                var b = new T[N - 1];
                Array.Copy(a, 1, b, 0, N - 1);
                for (int i = 0; i < a.Length; ++i)
                {
                    stack.Push(a[i]);
                    Search(perms, stack, b);
                    if (i < b.Length) { b[i] = a[i]; }
                    stack.Pop();
                }
            }
        }
        public static IEnumerable<T[]> All(IEnumerable<T> src)
        {
            var perms = new List<T[]>();
            Search(perms, new Stack<T>(), src.ToArray());
            return perms;
        }
    }







    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }
}
