from bisect import bisect_left, bisect_right n, m = map(int, input().split()) L = [-1 << 40] + list(map(int, input().split())) + [1 << 40] ans = 0 for _ in range(m): f, b, w = map(int, input().split()) p = bisect_left(L, f) dl = f - L[p - 1] dr = L[p] - f ans += max(b, w - min(dl, dr)) print(ans)