#include <bits/stdc++.h>

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;
#define X first
#define Y second
#define pb push_back

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e3 + 5;

vector<mp> adj[MAX];
ll dist[MAX];
map<ll, vector<ll>> dd;

int main()
{
    ll n, m, R; cin >> n >> m >> R;
    vector<ll> r(R); cin >> r;
    for (ll i = 0; i < m; i++) {
        ll a, b, c; cin >> a >> b >> c;
        adj[a].pb(mp(b, c));
        adj[b].pb(mp(a, c));
    }
    sort(r.begin(), r.end());
    for (ull i = 0; i < r.size(); i++) {
        ll s = r[i];
        for (ll j = 0; j < MAX; j++) dist[j] = INF;
        dist[s] = 0;
        priority_queue<mp, vector<mp>, greater<mp>> pq; pq.push(mp(0, s));
        while (!pq.empty()) {
            mp front = pq.top(); pq.pop();
            ll d = front.X, u = front.Y;
            if (d > dist[u]) continue;
            for (ull j = 0; j < adj[u].size(); j++) {
                mp v = adj[u][j];
                if (dist[u] + v.Y < dist[v.X]) {
                    dist[v.X] = dist[u] + v.Y;
                    pq.push(mp(dist[v.X], v.X));
                }
            }
        }
        for (ll j = 0; j < MAX; j++)
            dd[s].pb(dist[j]);
    }
    ll res = INF;
    do {
        ll r2 = 0;
        for (ull i = 1; i < r.size(); i++)
            r2 += dd[r[i - 1]].at(r[i]);
        res = min(res, r2);
    } while(next_permutation(r.begin(), r.end()));
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1280