#include <bits/stdc++.h>
using namespace std;
int getint() {
  int f = 1, x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
int n, m;
struct node {
  int l, r, t;
  node() {}
  node(int _, int __, int ___) {
    l = _;
    r = __;
    t = ___;
  }
} wal[612345];
bool byt(node x, node y) { return x.t < y.t; }
bool cmp(node x, node y) { return x.t - x.l < y.t - y.l; }
int mxpoint = 0, mnpoint = 1234567890;
map<int, int> ind;
int v[612345], tot;
void insert(int x, int k) {
  ind[x] = 0;
  ind[x + k] = 0;
}
int t[612345];
int pre[612345];
int find(int x) {
  int res = x;
  while (pre[res] != res) res = pre[res];
  int t;
  while (pre[x] != res) {
    t = pre[x];
    pre[x] = res;
    x = t;
  }
  return res;
}
pair<int, int> a[612345];
map<int, int> dk;
int main() {
  n = getint();
  m = getint();
  for (int i = 1; i <= m; i++) {
    int l = getint(), r = getint(), t = getint();
    wal[i] = node(l, r, t);
  }
  sort(wal + 1, wal + 1 + m, byt);
  for (int i = 1; i <= m; i++) {
    insert(wal[i].l, -1);
    insert(wal[i].r - 1, 1);
  }
  map<int, int>::iterator it;
  for (it = ind.begin(); it != ind.end(); it++) {
    v[++tot] = it->first;
    it->second = tot;
    pre[tot] = tot;
    t[tot] = -1;
  }
  pre[tot + 1] = tot + 1;
  for (int i = 1; i <= m; i++) {
    int l = ind[wal[i].l], r = ind[wal[i].r - 1], ti = wal[i].t;
    int y = find(r + 1);
    for (int j = l; j <= r; j++) {
      j = find(j);
      if (j <= r) t[j] = ti, pre[j] = y;
    }
  }
  m = 0;
  for (int i = 1; i <= tot; i++) {
    int l, r;
    l = r = i;
    while (r + 1 <= tot && t[r + 1] == t[i]) ++r;
    if (t[i] != -1) wal[++m] = node(l, r, t[i]);
    i = r;
  }
  tot = 0;
  for (int i = 1; i <= m; i++) {
    a[++tot] = make_pair(wal[i].t - v[wal[i].r] - 1, 1);
    a[++tot] = make_pair(wal[i].t - v[wal[i].l], -1);
  }
  sort(a + 1, a + 1 + tot);
  int j = 1, now = 0, k = 0;
  for (int i = 1; i <= n; i++) {
    int ti = getint();
    while (j <= tot && ti >= a[j].first) {
      now += max(0, a[j].first - a[j - 1].first) * k;
      k += a[j].second;
      j++;
    }
    int ans = now + k * (ti - a[j - 1].first);
    printf("%d\n", ans);
  }
  return 0;
}
