#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;

using lint = long long;
const lint MOD = 1e9 + 7;
const int INF = 1e9;
const lint LINF = 1e18;
using flt = double;
const flt E = exp(1.0);
const flt PI = acos(-1.0);

// Class ModInteger<MOD>
template <lint mod>
class ModInteger {
    public:
    lint val;

    // Constructor
    ModInteger(): val(0) {}
    ModInteger(lint ival): val(ival >= 0? ival%mod: mod - (-ival)%mod) {}

    // Comparators
    bool operator !() {return val == 0;}
    bool operator <(ModInteger that) {return val < that.val;}
    bool operator >(ModInteger that) {return val > that.val;}
    bool operator <=(ModInteger that) {return val <= that.val;}
    bool operator >=(ModInteger that) {return val >= that.val;}
    bool operator ==(ModInteger that) {return val == that.val;}
    bool operator !=(ModInteger that) {return val != that.val;}

    // Basic operations
    ModInteger operator ++() {val++; return *this;}
    ModInteger operator --() {val--; return *this;}

    ModInteger& operator +=(ModInteger that) {val = (val + that.val)%mod; return *this;}
    ModInteger& operator -=(ModInteger that) {val = ((val - that.val)%mod + mod)%mod; return *this;}
    ModInteger& operator *=(ModInteger that) {val = (val*that.val)%mod; return *this;}
    ModInteger& operator /=(ModInteger that) {
        lint inv = that.val, rem = 1, power = mod - 2;
        while (power > 1) {if (power%2) rem = (rem*inv)%mod; inv = (inv*inv)%mod; power /= 2;}
        inv = (rem*inv)%mod;
        val = (val*inv)%mod;
        return *this;
    }

    ModInteger operator +(ModInteger that) {return ModInteger(*this) += that;}
    ModInteger operator -(ModInteger that) {return ModInteger(*this) -= that;}
    ModInteger operator *(ModInteger that) {return ModInteger(*this) *= that;}
    ModInteger operator /(ModInteger that) {return ModInteger(*this) /= that;}
    
    ModInteger& operator %=(ModInteger that) {val = val%that.val; return *this;}
    ModInteger operator %(ModInteger that) {return ModInteger(*this) %= that;}
}; using mint = ModInteger<MOD>;

// ModInteger input & output
istream& operator >>(istream& is, mint& n) {return is >> n.val;}
ostream& operator <<(ostream& os, mint n) {return os << n.val;}

// Macros
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define bit(n) (lint)1<<n
#define mrep(it, m) for (auto it = m.begin(); it != num.end(); it++)
#define fi first
#define se second
#define pint pair<int, int>
#define plint pair<lint, lint>
#define mp make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vlint vector<lint>
#define vvlint vector<vector<lint>>
#define pb push_back
#define all(v) v.begin(), v.end()
#define asort(v) sort(all(v))
#define dsort(v) sort(all(v)); reverse(all(v))
#define maxval(v) *max_element(all(v))
#define maxindex(v) distance(v.begin(), max_element(all(v)))
#define minval(v) *min_element(all(v))
#define minindex(v) distance(v.begin(), min_element(all(v)))

// Sort by an arbitrary comparator (example)
/*
    sort(all(v), [](pint a, pint b) {return !(a.se == b.se)? a.se < b.se: a.fi < b.fi;});
*/

// Basic functions (be careful of overflowing!)
template <typename Tp>
Tp gcd(Tp m, Tp n) {
    if (!m || !n) {cout << "GCD error: zero inputed" << endl; return 0;}
    else if (!(m%n)) return n;
    else return gcd(n, m%n);
}
template <typename Tp>
Tp lcm(Tp m, Tp n) {
    if (!m || !n) {cout << "LCM error: zero inputed" << endl; return 0;}
    else return m*n/gcd(m, n);
}
template <typename Tp1, typename Tp2>
Tp1 ipow(Tp1 a, Tp2 p) {// For integers
    if (p < 0) {cout << "Power error: a minus number inputed" << endl; return 0;}
    else if (!p) return 1;
    Tp1 res = a, rem = 1;
    while (p > 1) {if (p%2) rem *= res; res *= res; p /= 2;}
    return rem*res;
}
template <typename Tp>
Tp fact(Tp n) {// Facorial: requires O(n)
    if (n < 0) {cout << "Factorial error: a minus number inputed" << endl; return 0;}
    else if (!n) return 1;
    else if (n == 1) return 1;
    else return n*fact(n - 1);
}
template <typename Tp>
void pfact(Tp n, map<Tp, int>& res) {// Prime factorization: requires O(sqrt(n))
    if (n <= 1) {cout << "Prime factorization error: cannot factorize an integer less than 2" << endl; return;}
    if (res.size()) cout << "Prime factorization warning: the map already contains some numbers" << endl;
    Tp pos = 2, pmax = n;
    while (pos*pos <= pmax) {if (!(n%pos)) {res[pos]++; n /= pos;} else pos++;}
    if (n != 1) res[n]++;
    return;
}
template <typename Tp>
Tp comb(Tp n, Tp r) {// Requires O(r)
    if (n < 0 || r < 0) {cout << "Combination error: a minus number inputed" << endl; return 0;}
    else {lint res = 1; rep(i, r) res *= (n - i)/(i + 1); return res;}
}

// Format for cout
/*
    // Integers
    cout << 42; -> 42
    cout << setfill('0') << setw(6) << 42; -> 000042

    // Floats
    cout << PI; -> 3.14159
    cout << fixed << PI; -> 3.141593 
    cout << fixed << setprecision(8) << PI; -> 3.14159265
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M, R;
    cin >> N >> M >> R;

    vint r(R);
    rep(i, R) {cin >> r[i]; r[i]--;}

    vvint dist(N, vint(N, INF));
    rep(i, M) {
        int A, B, C; cin >> A >> B >> C; A--; B--;
        dist[A][B] = dist[B][A] = C;
    }

    // Warshall–Floyd
    rep(k, N) rep(i, N) rep(j, N) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

    int ans = INF;
    sort(all(r));
    do {
        int cand = 0;
        rep(i, R - 1) cand += dist[r[i]][r[i + 1]];
        ans = min(ans, cand);
    } while (next_permutation(all(r)));

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384