#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//typedef __int128 lll;
#define PI 3.14159265358979323846
#define sbits(x) __builtin_popcountll(x)
#define tbits(total_size, num) ((total_size) - __builtin_clz(num))
#define pb push_back
#define f first
#define s second
#define clr(ds) ds.clear()
#define all(ds) ds.begin(), ds.end()
#define pi pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pi>
#define sz(i) (int)i.size()
using namespace std;
int xP[] = {0,0,1,-1,1,1,-1,-1} , yP[] = {1,-1,0,0,1,-1,-1,1};
uint64_t time() {
using namespace std::chrono;
return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
}
int rand(int a , int b){
return a + rand()%(b-a+1);
}
void setIO(string name = "") {
cin.tie(0)->sync_with_stdio(0);
if (name.size()) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
}
bool ckmin(auto& a , auto b){if(a<=b)return 0; else {a=b;return 1;}}
bool ckmax(auto& a , auto b){if(a>=b)return 0; else {a=b;return 1;}}
/*
_______________________________________
( If you don't fail at least 90% of the )
( time, you're not aiming high enough. )
( )
( - Alan Kay )
---------------------------------------
o ^__^
o (oo)\_______
(__)\ )\/\
||----w |
|| ||
*/
int n , m, k;
const int MAXN = 1e5;
int imp[5];
vpi adj[MAXN];
vll dist[MAXN];
const ll INF = 1e18;
void solve(){
auto djik = [&](int start){
dist[start] = vll(n, INF);
priority_queue<pi> pq;
pq.push({0 , start});
dist[start][start] = 0;
while(sz(pq)){
auto next = pq.top();
pq.pop();
ll curr = -next.f , node = next.s;
if(dist[start][node] != curr)continue;
for(auto& [neigh , weight] : adj[node])if(ckmin(dist[start][neigh] , curr + weight))
pq.push({-(curr + weight) , neigh});
}
};
cin >> n >> k >> m;
for(int i = 0;i<k;i++)cin >> imp[i], --imp[i];
for(int i = 0;i<m;i++){
int u , v , w;
cin >> u >> v >> w , --u ,--v , adj[u].pb({v , w}) , adj[v].pb({u , w});
}
for(int i = 0;i<k;i++)djik(imp[i]);
if(k==2){
cout << dist[imp[0]][imp[1]] << "\n";
return;
}
if(k==3){
ll ans = INF;
for(int i = 0;i<n;i++)ckmin(ans , dist[imp[0]][i] + dist[imp[1]][i] + dist[imp[2]][i]);
cout << ans << "\n";
return;
}
}
int main(){
setIO();
int t = 1;
// cin >> t;
while(t--){
solve();
}
}