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: if abs(l[idx-1]-f) < abs(l[idx]-f): ans+=max(w-(l[idx-1]-f), b) else: ans+=max(w-(l[idx]-f), b) else: ans+=max(w-(f-l[-1]),b) print(ans)