import sys input = sys.stdin.readline from heapq import * def dijkstra(): dist = [[10**18]*(10**4+10) for _ in range(N)] dist[0][T[0]] = T[0] pq = [(T[0], T[0])] while pq: d, vt = heappop(pq) v, t = divmod(vt, 10**6) if dist[v][t]dist[v][t]+w//t+T[nv]: dist[nv][t+T[nv]] = dist[v][t]+w//t+T[nv] heappush(pq, (dist[nv][t+T[nv]], nv*10**6+t+T[nv])) return min(dist[-1])-T[-1] N, M = map(int, input().split()) G = [[] for _ in range(N)] for _ in range(M): A, B, C = map(int, input().split()) G[A-1].append((B-1, C)) G[B-1].append((A-1, C)) T = list(map(int, input().split())) print(dijkstra())