#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

struct edge {
    int to, cost;
    edge(int to, int cost): to(to), cost(cost) {}
};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int INF = 1LL << 30;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

template <typename T = pair<int, int>>
void Dijkstra(int s, vector<vector<edge>> &g, vector<int> &d) {
    int numv = d.size();
    priority_queue<T, vector<T>, greater<T>> q;
    for (int i = 0; i < numv; ++i) d[i] = INF;
    d[s] = 0;
    q.emplace(0,s);

    while (!q.empty()) {
        T p = q.top(); q.pop();
        int v = p.second; // vertex
        if (d[v] < p.first) continue;
        for (int i = 0; i < g[v].size(); ++i) {
            edge e = g[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                q.emplace(d[e.to], e.to);
            }
        }
    }
}

void solve() {
    int n,m,r;
    cin >> n >> m >> r;
    VI rs(r);
    REP(i,0,r) {
        cin >> rs[i];
        --rs[i];
    }
    int a,b,c;
    vector<vector<edge>> es(n);
    REP(i,0,m) {
        cin >> a >> b >> c;
        --a; --b;
        es[a].pb(b,c);
        es[b].pb(a,c);
    }
    // Dijkustra
    VVI d(r, VI(n));
    REP(i,0,r) Dijkstra(rs[i], es, d[i]);

    VI ps(r);
    REP(i,0,r) ps[i] = i;
    int ans = INF;
    do {
        int sum = 0;
        REP(i,1,r) sum += d[ps[i]][rs[ps[i-1]]];
        ans = min(ans, sum);
    } while (next_permutation(all(ps)));
    cout << ans << endl;
    /*
    // bit DP
    VVI dp(1<<r,VI(r, INF));
    REP(i,0,r) dp[1<<i][i] = 0;
    REP(i,0,1<<r) {
        REP(j,0,r) {
            if (i & (1 << j) == 0) continue;
            REP(k,0,r) {
                if (i & (1 << k) != 0) continue;
                dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + d[j][rs[k]]);
            }
        }
    }
    cout << *min_element(all(dp[(1<<r)-1])) << endl;
    */
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 768