N, M = map(int, input().split()) A = list(map(int, input().split())) E = [] for _ in range(M): a, b, c = map(int, input().split()) E.append((a - 1, b - 1, A[b - 1] - c)) INF = 1 << 63 cost = [-INF] * N cost[0] = A[0] for _ in range(N - 1): for frm, to, t in E: if cost[frm] == -INF: continue if cost[to] < cost[frm] + t: cost[to] = cost[frm] + t update = [False] * N for _ in range(N): for frm, to, t in E: if cost[frm] == -INF: continue if cost[to] < cost[frm] + t: update[to] = True if update[frm]: update[to] = True for i in range(N): if update[i]: cost[i] = INF if cost[N - 1] == INF: print("inf") else: print(cost[N - 1])