n,m = map(int,input().split()) l = list(map(int,input().split())) from bisect import * ans = 0 for i in range(m): f,b,w = map(int,input().split()) ind = bisect_left(l,f) if ind == 0: if l[ind] == f: ans += w else: ans += max(b,w-(l[0]-f)) elif ind == n: if l[n-1] == f: ans += w else: ans += max(b,w-(f-l[n-1])) else: if l[ind] == f: ans += w else: tmp1 = w-(f-l[ind-1]) tmp2 = w-(l[ind]-f) ans += max(b,tmp1,tmp2) print(ans)