from heapq import * N, M = map(int, input().split()) A = list(map(int, input().split())) g = [] for _ in range(M): a, b, c = map(int, input().split()) a -= 1 b -= 1 g.append((a, b, c)) inf = 10 ** 18 dist = [-inf] * N dist[0] = 0 for i in range(N - 1): for u, v, c in g: if dist[u] != -inf and dist[v] < dist[u] + A[u] - c: dist[v] = dist[u] + A[u] - c for u, v, c in g: if dist[v] < dist[u] + A[u] - c: exit(print("inf")) print(dist[N - 1] + A[N - 1] if dist[N - 1] > -inf else "inf")