/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2021.03.31 23:22:59
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;




template<typename T>
struct Dijkstra {
private:
    int V;
    vector<int> P;
    struct edge { int to; T cost; };
    vector<vector<edge>> G;
public:
    const T inf = numeric_limits<T>::max();
    
    
    vector<vector<T>> d; 
    Dijkstra() {}
    Dijkstra(int V) : V(V) {
        G.resize(V);
        P.resize(V);
    }
    
    Dijkstra<T>& operator=(const Dijkstra<T>& obj) {
        this->V = obj.V;
        this->G = obj.G;
        this->d = obj.d;
        return *this;
    }
    
    
    void add_edge(int from, int to, T weight, bool directed = false) {
        G[from].push_back({to,weight});
        if (!directed) G[to].push_back({from,weight});
    }
    
    
    int add_vertex() {
        G.push_back(vector<edge>());
        return V++;
    }
    void set_vertex(int v, int p) {
        P[v] = p;
    }
    void build(int s) {
        d.assign(V, vector<T>(1002,INT_FAST16_MAX)); 
        typedef tuple<T, int, int> Q; 
        priority_queue<Q, vector<Q>, greater<Q>> pq;
        d[s][0] = 0; 
        pq.push(Q(d[s][0], s, 0)); 
        while (!pq.empty()) {
            Q p = pq.top(); pq.pop();
            int v = get<1>(p);
            int q = get<2>(p);
            
            if (d[v][q] < get<0>(p)) continue; 
            for (const edge &e : G[v])
            {
                
                if (d[e.to][min(1001,q+P[v])] > d[v][q] + e.cost/(q+P[v]) + P[v]) {
                    d[e.to][min(1001,q+P[v])] = d[v][q] + e.cost/(q+P[v]) + P[v];
                    pq.push(Q(d[e.to][min(1001,q+P[v])], e.to, min(1001,q+P[v])));
                }
            }
        }
    }
};
int main() {
    int n,m;cin >> n >> m;
    Dijkstra<ll> g(n);
    for (int i = 0; i < m; i++) {
        int a,b,c;cin >> a >> b >> c;
        a--;b--;
        g.add_edge(a,b,c);
    }
    for (int i = 0; i < n; i++) {
        int t;cin >> t;
        g.set_vertex(i,t);
    }
    g.build(0);
    ll ans = g.inf;
    for (int i = 0; i < g.d[n-1].size(); i++) {
        ans = min(ans,g.d[n-1][i]);
    }
    cout << ans << endl;
    return 0;
}