#include using namespace std; using ll=long long; using ld=long double; template using graph=vector>; template using min_priority_queue=priority_queue,greater>; constexpr int INF32=INT_MAX/2; constexpr ll INF64=1LL<<60; constexpr array DX4={0,1,0,-1}; constexpr array DY4={-1,0,1,0}; constexpr array DX8={0,1,1,1,0,-1,-1,-1}; constexpr array DY8={-1,-1,0,1,1,1,0,-1}; inline int popcnt(ll n){return __builtin_popcountll(n);} template inline bool chmax(T& a,const T& b){return a inline bool chmin(T& a,const T& b){return b=(ll)(n);i--) void _main(); int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); cout< using bint = boost::multiprecision::cpp_int; void _main(){ int N, M; cin >> N >> M; vector A(N); rep(i,0,N) cin >> A[i]; vector> edge; rep(i,0,M){ int a, b; cin >> a >> b; a--; b--; ll c; cin >> c; edge.emplace_back(a, b, c-A[b]); } bool inf = true; vector dist(N, LLONG_MAX); dist[0] = -A[0]; rep(i,0,N){ bool ok = true; for(auto [v, nv, c]:edge){ if(dist[v]==LLONG_MAX) continue; if(chmin(dist[nv], bint(dist[v]+c))) ok = false; } if(ok){ inf = false; break; } } if(inf) cout << "inf" << endl; else cout << -dist[N-1] << endl; }