#include using ll=long long; const long long INF=1LL<<60; struct Edge { int from; int to; long long cost; }; // 頂点Nにつながる負の閉路が存在する場合trueを返す bool BellmanFord(const std::vector& edges,std::vector& distances) { for(size_t i=0;i> n >> m; std::vectorA(n); for(auto&a:A)std::cin >> a; std::vectoredges(m); for(auto&edge:edges){ std::cin >> edge.from >> edge.to >> edge.cost; --edge.from;--edge.to; edge.cost-=A[edge.to]; } std::vectordistances(n,INF); distances[0]=-A[0]; if(BellmanFord(edges, distances)){ std::cout << "inf\n"; } else{ std::cout << -distances.back() << '\n'; } }