#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

vector<vector<LL>> d;

void warshall_floyd(int n) {
  REP(k,n){       // 経由する頂点
    REP(i,n){    // 始点
      REP(j,n){  // 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

// union find
class UnionFind {
private:
  vector<int> p;
  
public:
  UnionFind(int size) : p(size, -1) {}

  bool unionSet(int x, int y) {
    x = root(x);
    y = root(y);
    
    if (x != y) {
      if (x > y) { swap(x, y); }
      p[x] += p[y];
      p[y] = x;
    }   

    return x != y;
  }

private:
  int root(int x) {
    return p[x] < 0 ? x : p[x] = root(p[x]);
  }
};

// 辺
struct edge {
  int x, y;
  int cost;
  edge(int x, int y, double cost) : x(x), y(y), cost(cost) {}

  // ソート用
  bool operator <(const edge& rhs) const {
    return cost < rhs.cost;
  }
};

vector<edge> es;

LL kruskal(int n) {
    SORT_ASC(es);
    UnionFind uf = UnionFind(n);
    LL res = 0;

    REP(i,SIZE(es)){
        edge e = es[i];
        if (uf.unionSet(e.x, e.y)) {
            res += e.cost;
        }
    }
    return res;
}


void Main()
{
    int n,m,R;cin>>n>>m>>R;
    VI r(R);
    REP(i,R){
        cin>>r[i];
        r[i]--;
    }

    d.resize(n);
    REP(i,n){
        d[i].resize(n,INF_LL);
        d[i][i]=0;
    }
    REP(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        d[a][b]=c;
        d[b][a]=c;
    }

    warshall_floyd(n);
    /*
    REP(i,n){
        REP(j,n){
            cerr<< d[i][j] << " ";
        }
        cerr<<endl;
    }
    */
    
    LL result = INF_LL;
    VI v(R);
    iota(ALL(v), 1);       // v に 1, 2, ... N を設定
    do {
        LL dist = 0;
        REP(i,R-1){
            int x = r[v[i]-1];
            int y = r[v[i+1]-1];
            dist += d[x][y];
        }
        result = min(result,dist);
    } while( next_permutation(ALL(v)) );     // 次の順列を生成

    cout << result << endl;




    /*   
    REP(i,R){
        FOR(j,i+1,R){
            int x = r[i];
            int y = r[j];
            es.push_back(edge(x,y,d[x][y]));
        }
    }

    LL result = kruskal(n);

    cout << result << endl;
    */

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 640