n,m,k=map(int,input().split()) r=[-1]*m for i,v in enumerate(list(map(int,input().split()))): r[v-1]=i e=[[] for i in range(n)] for i in range(m): a,b,c=map(int,input().split()) a-=1 b-=1 e[a]+=[(i,b,c)] e[b]+=[(i,a,c)] from heapq import heappush,heappop X=10**10 v=[[X]*n for i in range(1<0: sc,sp,sy=heappop(q) if sc>v[sp][sy]: continue for i,ty,tc in e[sy]: if r[i]!=-1: tp=sp|(1<sc+tc: v[tp][ty]=sc+tc heappush(q,(v[tp][ty],tp,ty)) print(v[-1][-1])