#include "bits/stdc++.h" //#include "atcoder/all" using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" using A = array; struct Edge { int to, cost; Edge(int to, int cost) :to(to), cost(cost) {} }; int N, M; vectorg[100005]; long long T[105]; long long d[101][1001]; long long dikstra() { rep(i, N) { rep(j, 1001) { d[i][j] = LINF; } } priority_queue, greater > q;//小さいもの順 q.push({ 0,0,0 }); d[0][0] = 0; while (!q.empty()) { long long c = q.top()[0]; long long v = q.top()[1]; long long p = q.top()[2]; q.pop(); if (c > d[v][p]) { continue; } c += T[v]; p = min(p + T[v], (long long)1000); for (Edge e : g[v]) { if (c + e.cost / p < d[e.to][p]) { d[e.to][p] = c + e.cost / p; q.push({ d[e.to][p],e.to,p }); } } } long long ret = LINF; rep(i, 1001) { ret = min(ret, d[N - 1][i]); } return ret; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> M; rep(i, M) { int a, b, c; cin >> a >> b >> c; a--; b--; g[a].emplace_back(b, c); g[b].emplace_back(a, c); } rep(i, N) { cin >> T[i]; } cout << dikstra() << endl; return 0; }