import sys input = sys.stdin.readline n,m,l = map(int,input().split()) l -= 1 T = list(map(int,input().split())) inf = pow(10,20) from heapq import heapify, heappop, heappush def Dijkstra(n,path,start): d = [inf]*n d[start] = 0 pq = [(0, start)] heapify(pq) while pq: dist, p = heappop(pq) if dist > d[p]:continue for nxt,cost in path[p].items(): if dist + cost >= d[nxt]:continue d[nxt] = dist + cost heappush(pq,(d[nxt],nxt)) return d path = [{} for _ in range(n)] for i in range(m): a,b,c = map(int,input().split()) a -= 1 b -= 1 path[a][b] = c path[b][a] = c ld = Dijkstra(n,path,l) def total(n,path,t,start,ld): d = Dijkstra(n,path,start) res = 0 delta = ld[start] for i in range(n): res += 2*d[i]*t[i] if t[i] > 0: delta = min(delta, ld[i] - d[i]) if res == 0:return res else: return res + delta ans = inf for i in range(n): ans = min(ans,total(n,path,T,i,ld)) print(ans)