#include using namespace std; int main() { int N, M; cin >> N >> M; vector A(N); for(int i = 0; i < N; i++) { cin >> A[i]; } vector a(M), b(M); vector c(M); for(int i = 0; i < M; i++) { cin >> a[i] >> b[i] >> c[i]; a[i]--, b[i]--; } const long long INF = 1LL<<55; vector dp(N, INF); dp[0] = 0; for(int i = 0; i < N; i++) { for(int j = 0; j < M; j++) { if(dp[b[j]] > dp[a[j]]-(A[a[j]]-c[j])) { dp[b[j]] = dp[a[j]]-(A[a[j]]-c[j]); } } } for(int j = 0; j < M; j++) { if(dp[b[j]] > dp[a[j]]-(A[a[j]]-c[j])) { cout << "inf" << endl; return 0; } } cout << A[N-1]-dp[N-1] << endl; }