#MMA Contest 018 G N, M = map(int, input().split()) A = list(map(int, input().split())) G = [[] for _ in range(N)] for _ in range(M): a, b, c = map(int, input().split()) a, b = a - 1, b - 1 G[a].append((b, A[b] - c)) #DP[i]: ダンジョンiに到達したときの満足度の最大値 DP = [- 10 ** 18] * N DP[0] = A[0] #M回のBellman-Ford for _ in range(M): for i in range(N): for j, c in G[i]: if DP[j] < DP[i] + c: DP[j] = min(DP[i] + c, 10 ** 18) #もう1回Bellman-Ford 正回路があればinfに変更 for i in range(N): for j, c in G[i]: if DP[j] < DP[i] + c: DP[j] = 10 ** 18 #M回Bellman-Ford for _ in range(M): for i in range(N): if DP[i] != 10 ** 18: continue for j, c in G[i]: if DP[j] < DP[i] + c: DP[j] = 10 ** 18 #答えを出力 print(DP[-1] if DP[-1] < 10 ** 18 else 'inf')