#include <iostream>
//#include<atcoder/all>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> 
#include <vector>
#include <algorithm>
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue>
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set>
#include <bitset> 
#include <cctype>
//using namespace atcoder;
using namespace std;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<pair<ll, ll>>>;
vector<bool> seen;
bool C = true;
vector<ll> dist;


int main() {
	ll N, M;
	cin >> N >> M;
	Graph G(N);
	rep(i, M) {
		ll A, B, C;
		cin >> A >> B >> C;
		A--; B--;
		G[A].push_back(make_pair(B, C));
		G[B].push_back(make_pair(A, C));
	}
	vll T(N);
	rep(i, N)cin >> T[i];
	vector<vll> dist(N, vll(N * 105, 1e18));
	priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> Q;
	dist[0][T[0]] = T[0];
	Q.push(make_pair(0, T[0]));
	while (!Q.empty()) {
		auto p = Q.top();
		Q.pop();

		for (auto k : G[p.first]) {
			if (p.second + T[k.first] >= N * 101)continue;
			if (dist[k.first][p.second + T[k.first]] > dist[p.first][p.second] + k.second / p.second + T[k.first]) {
				dist[k.first][p.second + T[k.first]] = dist[p.first][p.second] + k.second / p.second + T[k.first];
				Q.push(make_pair(k.first, p.second + T[k.first]));
			}
		}
	}
	ll an = 1e18;
	rep(t, N * 101) {
		an = min(an, dist[N - 1][t]);
	}
	cout << an << endl;
}