N,M = map(int,input().split()) G = [[] for _ in range(N)] for _ in range(M): a,b,c = map(int,input().split()) a -= 1 b -= 1 G[a].append((b,c)) G[b].append((a,c)) T = list(map(int,input().split())) inf = 1000 dist = [[10 ** 6] * (inf + 1) for _ in range(N)] dist[0][T[0]] = 0 q = [(0,0,0)] import heapq while q: d,now,time = heapq.heappop(q) #print(d,now,time) if dist[now][time] < d:contnue if now == N - 1:break time += T[now] d += T[now] if time > inf: time = inf for v,c in G[now]: tmp = d + c // time if dist[v][time] > tmp: dist[v][time] = tmp heapq.heappush(q,(tmp,v,time)) ans = 10 ** 6 for time in range(inf + 1): if ans > dist[-1][time]: ans = dist[-1][time] print(ans)