from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd n,m = map(int,input().split()) l = list(map(int,input().split())) ans=0 for _ in range(m): f,b,w = map(int,input().split()) idx=bisect_left(l,f) if idx == 0: ans+=max(w-(l[idx]-f), b) elif idx < n: ans+=max(w-(f-l[idx-1]),w-(l[idx]-f), b) else: ans+=max(w-(f-l[-1]),b) print(ans)