// #includes {{{
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug_v(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;
template<class T>
T inf(){ return (numeric_limits<T>::max()>>1);}

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

//{{{ io
FILE *file_in=stdin,*file_out=stdout;
#define fin normal_in
#define fout normal_out
//const char fname[]="";
//FILE *fin=fopen(fname,"r"),*fout=fopen(fname,"w");
#ifdef __MINGW32__
#define LLD "%I64d"
#define LLU "%I64u"
#else
#define LLD "%lld"
#define LLU "%llu"
#endif
struct NORMAL_IN{
	bool cnt;
	NORMAL_IN():cnt(true){}
	operator int() const {return cnt;}
#define endl "\n"
	NORMAL_IN& operator>>(int &n){cnt=fscanf(file_in,"%d",&n)!=EOF;return *this;}
	NORMAL_IN& operator>>(unsigned int &n){cnt=fscanf(file_in,"%u",&n)!=EOF;return *this;}
	NORMAL_IN& operator>>(long long &n){cnt=fscanf(file_in,LLD,&n)!=EOF;return *this;}
	NORMAL_IN& operator>>(unsigned long long &n){cnt=fscanf(file_in,LLU,&n)!=EOF;return *this;}
	NORMAL_IN& operator>>(double &n){cnt=fscanf(file_in,"%lf",&n)!=EOF;return *this;}
	NORMAL_IN& operator>>(long double &n){cnt=fscanf(file_in,"%Lf",&n)!=EOF;return *this;}
	NORMAL_IN& operator>>(char *c){cnt=fscanf(file_in,"%s",c)!=EOF;return *this;}
	NORMAL_IN& operator>>(string &s){
		s.clear();
		for(bool r=false;;){
			const char c=getchar();
			if(c==EOF){ cnt=false; break;}
			const int t=isspace(c);
			if(!r and !t)r=true;
			if(r){
				if(!t)s.push_back(c);
				else break;
			}
		}
		return *this;
	}
	template<class T>
		NORMAL_IN& operator>>(vector<T> &v){
			int n;fscanf(file_in,"%d",&n);
			REP(i,n){
				T t;*this>>t;
				v.push_back(t);
			}
		}
} normal_in;

struct NORMAL_OUT{
	NORMAL_OUT& operator<<(const int &n){fprintf(file_out,"%d",n);return *this;}
	NORMAL_OUT& operator<<(const unsigned int &n){fprintf(file_out,"%u",n);return *this;}
	NORMAL_OUT& operator<<(const long long &n){fprintf(file_out,LLD,n);return *this;}
	NORMAL_OUT& operator<<(const unsigned long long &n){fprintf(file_out,LLU,n);return *this;}
	NORMAL_OUT& operator<<(const double &n){fprintf(file_out,"%lf",n);return *this;}
	NORMAL_OUT& operator<<(const long double &n){fprintf(file_out,"%Lf",n);return *this;}
	NORMAL_OUT& operator<<(const char c[]){fprintf(file_out,"%s",c);return *this;}
	NORMAL_OUT& operator<<(const string &s){fprintf(file_out,"%s",s.c_str());return *this;}
} normal_out;
//}}}

//{{{ Print functions
// Input/Output
template<class T>
void matrix_out(const vector<vector<T> > &x){
	REP(i,x.size()){
		REP(j,x[0].size()){
			cout<<x[i][j]<<"\t";
		}
		cout<<endl;
	}
}

template<class U,class S,class T>
U &operator<<(U &os, const pair<S,T> &p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

void printBit(int b,int k=-1){
	if(k==-1){
		int bb=1,i=0;
		while(bb){
			if(b&bb)k=i;
			bb<<=1;i++;
		}
	}
	REP(ct,k){
		cout<<b%2;
		b>>=1;
	}
	cout<<endl;
}

template<typename U, template <typename... Args> class Container,typename... Types>
U &operator<<(U &os, const Container<Types...> &x) {
	os<<"{";
	for(const auto &e:x)os<<" "<<e<<" ";
	os<<"}";
	return os;
}
//}}}
//{{{ Graph<Weight>
typedef Int Weight;
typedef int Node;
template<class Weight>
struct edge {
	int src, dst, rev;
	Weight weight;
	edge(int src, int dst, Weight weight=1,int rev=-1) :
		src(src), dst(dst), weight(weight), rev(rev){ }
};
template<class Weight>
bool operator < (const edge<Weight> &e, const edge<Weight> &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
		e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
//typedef vector<edge> edges;
//typedef vector<edges> Graph;
 
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
 
template<class Weight>
struct graph:vector<vector<edge<Weight> > >{
	Weight inf{::inf<Weight>()};
	graph(){}
	graph(const int &n):vector<vector<edge<Weight> > >(n){}
	void _add_edge(int from, int to, Weight w, int rev=-1){
		if(this->size() < from + 1)this->resize(from + 1);
		this->at(from).push_back(edge<Weight>(from,to,w,rev));
	}
};
//add bi-directional edge
template<class Weight>
void addBiEdge(graph<Weight> &g, const pair<int,int> &e, Weight w=1){
	const int &from = e.first, &to = e.second;
	g._add_edge(from,to,w,g[to].size());
	g._add_edge(to,from,w,g[from].size()-1);
}
//add directional edge
template<class Weight>
void addEdge(graph<Weight> &g, const pair<int,int> &e, Weight w=1){
	const int &from = e.first, &to = e.second;
	g._add_edge(from,to,w);
}

typedef edge<Weight> Edge;
typedef graph<Weight> Graph;

#ifdef DEBUG
#include"graph/graphviz.h"
#endif
//}}}

void shortestPath(const Matrix &g,
    Matrix &dist, vector< vector<int> > &inter) {
  int n = g.size();
  dist = g;
  inter.assign(n, vector<int>(n,-1));
  REP(k, n) REP(i, n) REP(j, n) {
    if (dist[i][j] > dist[i][k] + dist[k][j]) {
      dist[i][j] = dist[i][k] + dist[k][j];
      inter[i][j] = k;
    }
  }
}
void buildPath(const vector< vector<int> > &inter,
    int s, int t, vector<int> &path) {
  int u = inter[s][t];
  if (u < 0) path.push_back(s);
  else buildPath(inter, s, u, path), buildPath(inter, u, s, path);
}
vector<int> buildPath(
    const vector< vector<int> > &inter, int s, int t) {
  vector<int> path;
  buildPath(inter, s, t, path);
  path.push_back(t);
  return path;
}

void solve(long long N, long long M, long long R, vector<long long> r, vector<long long> A, vector<long long> B, vector<long long> C){
	Matrix G(N,Array(N,inf<int>()));
	REP(i,N)G[i][i] = 0;
	REP(i,M){
		G[A[i]][B[i]]=min(G[A[i]][B[i]],C[i]);
		G[B[i]][A[i]]=min(G[B[i]][A[i]],C[i]);
	}
	Matrix dist;
	vector<vector<int> > inter;
	shortestPath(G,dist,inter);
	vector<int> v(R);
	REP(i,R)v[i] = i;
	Int ans0 = inf<int>();
	do{
		Int ans = 0;
		REP(i,R-1){
			ans += dist[r[v[i]]][r[v[i+1]]];
		}
		ans0 = min(ans,ans0);
	}while(next_permutation(ALL(v)));
	fout<<ans0<<endl;
}

int main(){	
	long long M;
	long long R;
	long long N;
	fin >> N;
	fin >> M;
	vector<long long> A(M-1+1);
	vector<long long> B(M-1+1);
	vector<long long> C(M-1+1);
	fin >> R;
	vector<long long> r(R-1+1);
	for(int i = 0 ; i <= R-1 ; i++){
		fin >> r[i];
		r[i]--;
	}
	for(int i = 0 ; i <= M-1 ; i++){
		fin >> A[i];
		fin >> B[i];
		fin >> C[i];
		A[i]--;B[i]--;
	}
	solve(N, M, R, r, A, B, C);
	return 0;
}



Measured memory_bytes: 2048