#include template inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}} template inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}} #define ll long long #define double long double #define rep(i,n) for(int i=0;i<(n);i++) #define REP(i,n) for(int i=1;i<=(n);i++) #define mod (ll)(1e9+7) #define inf (ll)(3e18+7) #define eps (double)(1e-9) #define pi (double) acos(-1) #define P pair //#define PiP pair> #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() using namespace std; using PiP = pair>; struct edge { ll to, cost; }; int main() { int n, m; cin >> n >> m; vector> G(n); vector T(n); rep(i, m){ ll a, b, c; cin >> a >> b >> c; a--; b--; G[a].push_back({b, c}); G[b].push_back({a, c}); } rep(i, n)cin >> T[i]; vector> d(n, vector(100010, inf)); priority_queue, greater> que; d[0][0] = 0; que.push({0, {0, 0}}); while(!que.empty()){ PiP p = que.top(); que.pop(); ll v = p.second.first; ll t = p.second.second; if(p.first > d[v][t])continue; for(auto x : G[v]){ ll cst = d[v][t] + T[v] + (x.cost / (t + T[v])); if(t + T[v] >= 100010)continue; if(chmin(d[x.to][t + T[v]], cst)){ que.push({cst, {x.to, t + T[v]}}); } } } ll ans = inf; rep(i, 100010)chmin(ans, d[n-1][i]); cout << ans << endl; }