#include <bits/stdc++.h>

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

/*GRAPH_TEMPLATE=============================================*/
template<typename T>
class Edge {
public:
    int src;  // source 状態記録「null = -1」
    int to;  // 辺の行き先
    T cost;  // 辺の重み
    Edge(int t, T w) : src(-1), to(t), cost(w) {}
    Edge(int t, T w, int src) : src(src), to(t), cost(w) {}
};
template<typename T>
using W_Graph = std::vector<std::vector<Edge<T>>>;   //重み付きグラフ
using Graph = std::vector<std::vector<int>>;         //通常グラフ
template<typename T>
using Matrix = std::vector<std::vector<T>>;          //隣接行列(使わなさそう...)

/*隣接行列表現でi==jの要素を0、隣接している部分を重みで、他をinfで初期化しておく*/
template<class T>
void Warshall_Floyd(Matrix<T> &G, T inf) {
    for(int k = 0; k < G.size(); k++) {
        for(int i = 0; i < G.size(); i++) {
            for(int j = 0; j < G.size(); j++) {
                if(G[i][k] == inf || G[k][j] == inf) continue;
                G[i][j] = std::min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
}
/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n, m, r, a,b,c; cin >> n >> m >> r;
    vec<i32> cities(r);
    rep(i,r) {
        cin >> cities[i];
        --cities[i];
    }
    vii graph(n, vi(n, inf));
    rep(i,n) graph[i][i] = 0;
    rep(i,m) {
        cin  >> a >> b >> c;
        --a, --b;
        graph[a][b] = graph[b][a] = c;
    }
    Warshall_Floyd<i32> (graph, inf);


    vi order(r); rep(i,r) order[i] = i;
    i32 ans = inf, tmp;
    do {
        tmp = 0;
        for(i32 i = 0; i < r-1; ++i) {
            i32 I = order[i], J = order[i+1];
            tmp += graph[cities[I]][cities[J]];
        }
        chmin(ans, tmp);
    } while (next_permutation(all(order)));

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 640