import sys input = sys.stdin.readline from bisect import bisect_left N,M=map(int,input().split()) L=[-(1<<60)]+list(map(int,input().split()))+[1<<60] FBW=[list(map(int,input().split())) for _ in range(M)] ans=0 for f,b,w in FBW: i = bisect_left(L, f) if L[i]==f: ans += w else: ans += max(b, w-(f-L[i-1]), w-(L[i]-f)) print(ans)