from bisect import bisect_left N, M = map(int, input().split()) L = list(map(int, input().split())) FBW = [list(map(int, input().split())) for _ in range(M)] ans = 0 for F, B, W in FBW: b = bisect_left(L, F) if b < N and L[b] == F: ans += W continue MAX = B if 1 <= b: MAX = max(MAX, W-(F-L[b-1])) if b < N: MAX = max(MAX, W-(L[b]-F)) ans += MAX print(ans)