N,M=map(int, input().split()) L=list(map(int, input().split())) A=L.copy() A.append(-10**12) A.append(10**12) A=sorted(A) LL=set(L) import bisect ans=0 for i in range(M): f,b,w=map(int, input().split()) if f in LL: ans+=w else: d=bisect.bisect_left(A,f) x,y=A[d-1],A[d] p=max(b,w-abs(f-x),w-abs(f-y)) ans+=p print(ans)