R=range J=lambda:map(int,input().split()) N,M=J() A=list(J()) E=[[]for i in R(N*2)] F=[] for i in R(N):E[i]+=[i+N];F+=[[i,i+N,-A[i]]] for j in R(M):a,b,c=J();a=a-1+N;E[a]+=[b-1];F+=[[a,b-1,c]] N*=2 W=[0]+[9**20]*N for _ in R(N): for i,j,w in F:W[j]=min(W[j],W[i]+w) b=[1]*N for i,j,w in F:b[i]&=W[j]<=W[i]+w D=[i for i in R(N)if b[i]<1] while D: for j in E[D.pop()]:D+=[j]*b[j];b[j]=0 print(["inf",-W[N-1]][b[N-1]])