#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T qmin(const T a, const T b) {
  return a < b ? a : b;
}
template <typename T>
inline T qmax(const T a, const T b) {
  return a > b ? a : b;
}
template <typename T>
inline void getmin(T &a, const T b) {
  if (a > b) a = b;
}
template <typename T>
inline void getmax(T &a, const T b) {
  if (a < b) a = b;
}
inline void fileio(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
const int inf = 1e9 + 7;
const long long linf = 1e17 + 7;
const int N = 4e5 + 107;
int pos[N], first[N], par[N], m;
int l[N], r[N], t[N];
int p[N];
int n, q;
inline int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }
inline bool cmp(const int &x, const int &y) { return t[x] < t[y]; }
int main() {
  scanf("%d%d", &q, &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d%d%d", l + i, r + i, t + i), pos[++m] = l[i], pos[++m] = r[i],
                                          p[i] = i;
  sort(pos + 1, pos + m + 1);
  m = unique(pos + 1, pos + m + 1) - pos - 1;
  sort(p + 1, p + n + 1, cmp);
  for (int i = 1; i <= m; ++i) par[i] = i, first[i] = -1;
  for (int i = 1; i <= n; ++i) {
    int ul = lower_bound(pos + 1, pos + m + 1, l[p[i]]) - pos;
    int ur = lower_bound(pos + 1, pos + m + 1, r[p[i]]) - pos;
    for (int k = find(ul); k < ur; k = find(k))
      first[k] = t[p[i]], par[k] = k + 1;
  }
  int sz = 0;
  if (~first[1]) t[++sz] = first[1] - pos[1];
  for (int i = 1; i < m; ++i) {
    if (first[i] == first[i + 1]) continue;
    if (~first[i]) t[++sz] = first[i] - pos[i + 1];
    if (~first[i + 1]) t[++sz] = first[i + 1] - pos[i + 1];
  }
  assert(!(sz & 1));
  for (int i = 1; i <= sz; ++i) p[i] = i;
  sort(p + 1, p + sz + 1, cmp);
  for (int i = 1, cur = -inf, ans = 0, cnt = 0, j = 1; i <= q; ++i) {
    int st;
    scanf("%d", &st);
    for (; j <= sz && t[p[j]] <= st; ++j) {
      ans += cnt * (t[p[j]] - cur);
      cnt += (p[j] & 1 ? -1 : 1);
      cur = t[p[j]];
    }
    ans += cnt * (st - cur);
    cur = st;
    printf("%d\n", ans);
  }
  return 0;
}
