#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 100005;
inline int read() {
  int res, ok = 1;
  char ch;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') ok = -1;
  res = ch - '0';
  for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
    res = res * 10 + ch - '0';
  return res * ok;
}
int n, m, num, sum, cnt = -1, q[maxn];
pair<int, int> a[maxn << 1], b[maxn * 5];
multiset<int> s;
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    int l, r, t;
    l = read();
    r = read();
    t = read();
    num++;
    a[num] = make_pair(l, t);
    num++;
    a[num] = make_pair(r, -t - 1);
  }
  sort(a + 1, a + 1 + num);
  for (int i = 1, j = 1; i <= num; i = j) {
    while (j <= num && a[i].first == a[j].first) j++;
    for (int k = i; k < j; k++) {
      if (a[k].second >= 0)
        s.insert(a[k].second);
      else
        s.erase(s.find(-a[k].second - 1));
    }
    int now = s.empty() ? -1 : *s.begin();
    if (cnt != -1) {
      sum++;
      b[sum] = make_pair(cnt - a[i].first, 1);
    }
    if (now != -1) {
      sum++;
      b[sum] = make_pair(now - a[i].first, -1);
    }
    cnt = now;
  }
  for (int i = 1; i <= n; i++) {
    int x = read();
    sum++;
    b[sum] = make_pair(x, i + 1);
  }
  sort(b + 1, b + 1 + sum);
  int l = 0, r = 0;
  for (int i = 1; i <= sum; i++) {
    if (i > 1) l += r * (b[i].first - cnt);
    if (b[i].second <= 1)
      r += b[i].second;
    else
      q[b[i].second - 1] = l;
    cnt = b[i].first;
  }
  for (int i = 1; i <= n; i++) printf("%d\n", q[i]);
  return 0;
}
