using System;
using System.Collections.Generic;
using System.Linq;

public static class Permutation
{
    public static int Factorial(int n)
    {
        if (n == 0)
        {
            return 1;
        }
        return n * Factorial(n - 1);
    }

    public static IEnumerable<int[]> GetPermutations(int n)
    {
        int max = Factorial(n);
        for (int i = 0; i < max; i++)
        {
            yield return GetPermutation(n, i);
        }
    }

    public static int[] GetPermutation(int n, int serialNum)
    {
        var m = new int[n];
        for (int i = 0; i < n; i++)
        {
            m[i] = i;
        }

        var perm = new int[n];
        int cur = 0;
        for (int i = n; i >= 1; i--)
        {
            int nn = serialNum % i;
            perm[cur++] = m[nn];
            for (int j = nn; j < i - 1; j++)
            {
                m[j] = m[j + 1];
            }
            serialNum = serialNum / i;
        }
        return perm;
    }
}

public class PriorityQueue<TKey, TValue>
{
    SortedDictionary<TKey, HashSet<TValue>> dict = new SortedDictionary<TKey, HashSet<TValue>>();
    Dictionary<TValue, TKey> rDict = new Dictionary<TValue, TKey>();
    int count = 0;

    public int Count
    {
        get
        {
            return count;
        }
    }

    public void Enqueue(TKey key, TValue value)
    {
        if (!dict.ContainsKey(key))
        {
            dict[key] = new HashSet<TValue>();
        }

        dict[key].Add(value);
        rDict[value] = key;
        count++;
    }

    public KeyValuePair<TKey, TValue> Dequeue()
    {
        var queue = dict.First();
        if (queue.Value.Count <= 1)
        {
            dict.Remove(queue.Key);
        }

        var val = queue.Value.First();
        queue.Value.Remove(val);
        count--;
        rDict.Remove(val);
        return new KeyValuePair<TKey, TValue>(queue.Key, val);
    }

    public KeyValuePair<TKey, TValue> Peek()
    {
        var queue = dict.First();
        var val = queue.Value.First();
        return new KeyValuePair<TKey, TValue>(queue.Key, val);
    }

    public void ChangePriority(TKey newKey, TValue value)
    {
        ChangePriority(rDict[value], newKey, value);
    }

    public void ChangePriority(TKey prevKey, TKey newKey, TValue value)
    {
        var set = dict[prevKey];
        set.Remove(value);
        if (set.Count == 0)
        {
            dict.Remove(prevKey);
        }
        count--;

        Enqueue(newKey, value);
    }

    public bool ContainsValue(TValue val)
    {
        return rDict.ContainsKey(val);
    }
}


class Solution
{
    static long[] Dijkstra(List<Tuple<int, long>>[] link, int k)
    {
        var n = link.Length - 1;
        var d = Enumerable.Repeat(long.MaxValue, n + 1).ToArray();
        d[k] = 0;
        var q = new PriorityQueue<long, int>();
        q.Enqueue(0, k);

        while (q.Count > 0)
        {
            var u = q.Dequeue();
            foreach (var nei in link[u.Value])
            {
                var v = nei.Item1;
                var len = nei.Item2;
                if (d[v] > d[u.Value] + len)
                {
                    d[v] = d[u.Value] + len;
                    if (q.ContainsValue(v))
                    {
                        q.ChangePriority(d[v], v);
                    }
                    else
                    {
                        q.Enqueue(d[v], v);
                    }
                }
            }
        }

        return d;
    }

    public static long SolveByBruteForce(List<Tuple<int, long>>[] link, IList<int> target)
    {
        long min = long.MaxValue;
        foreach (var pattern in Permutation.GetPermutations(target.Count))
        {
            long d = 0;
            var cur = target[pattern[0]];
            for (int i = 1; i < pattern.Length; i++)
            {
                var next = target[pattern[i]];
                d += link[cur].First(l => l.Item1 == next).Item2;
                cur = next;

                if (d >= min)
                {
                    break;
                }
            }
            if (d < min)
            {
                min = d;
            }
        }

        return min;
    }

    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = vals[0];
        var m = vals[1];
        var rCount = vals[2];
        var r = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var link = Enumerable.Range(0, n + 1).Select(_ => new List<Tuple<int, long>>()).ToArray();
        for (int i = 0; i < m; i++)
        {
            var v = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            link[v[0]].Add(Tuple.Create(v[1], (long)v[2]));
            link[v[1]].Add(Tuple.Create(v[0], (long)v[2]));
        }

        foreach (var start in r)
        {
            var distance = Dijkstra(link, start);

            link[start] = new List<Tuple<int, long>>();
            foreach (var end in r)
            {
                if (end != start)
                {
                    link[start].Add(new Tuple<int, long>(end, distance[end]));
                }
            }
        }

        var d = SolveByBruteForce(link, r);
        Console.WriteLine(d);
    }
}

Measured memory_bytes: 20296