#include using namespace std; using ll = long long; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, M; ll P; cin >> N >> M; vector S(N); for(int i=0;i>S[i]; vector>> G(N); vector> IG(N); for (int i = 0; i < M; i++) { ll A, B, C; cin >> A >> B >> C; A--; B--; G[A].push_back({ B,S[B]-C }); IG[B].push_back(A); } vector CGOAL(N, 0); queue Q; Q.push(N - 1); while (!Q.empty()) { int p = Q.front(); Q.pop(); if (CGOAL[p])continue; CGOAL[p] = 1; for (auto v : IG[p]) { if (!CGOAL[v])Q.push(v); } } // cout<<"P"< D(N, -1e18); D[0] = 0; for (ll m = 0; m < max(M, N) * 2; m++) { for (ll n = 0; n < N; n++) { for (auto v : G[n]) { ll nd = D[n] + v.second; ll nv = v.first; D[nv] = max(D[nv], nd); } } } bool E = 0; for (ll n = 0; n < N; n++) { for (auto v : G[n]) { ll nd = D[n] + v.second; ll nv = v.first; if (nd > D[nv]) { if (CGOAL[nv]&&D[nv]>-1e17)E = 1; } } } if (E)cout << "inf" << endl; else cout << max(0ll, D[N - 1]+S[0]) << endl; }