from heapq import heapify, heappop, heappush
from collections import defaultdict

n, m = map(int, input().split())
edge = defaultdict(list)
max_c = 0
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    max_c = max(max_c, c)
    edge[a].append((b, c))
    edge[b].append((a, c))
T = list(map(int, input().split()))

INF = 10**18
D = [[INF for _ in range(max_c + 2)] for _ in range(n)]
D[0][0] = 0

H = [(0, 0, 0)]
heapify(H)
while H:
    t, cp, et = heappop(H)
    if D[cp][et] < t:
        continue
    t += T[cp]
    et = min(et + T[cp], max_c + 1)
    for np, tt in edge[cp]:
        if D[np][et] > t + tt // et:
            D[np][et] = t + tt // et
            heappush(H, (t + tt // et, np, et))
print(min(D[n - 1]))