#include <bits/stdc++.h>
using namespace std;
const int N = 200500;
const int M = 530000;
const int inf = 1987654321;
struct Info {
  int l, r;
  int val;
} xu[N];
int jie[N];
int lsa[N], lsb[M];
int z[M];
struct node {
  node *lson, *rson;
  int l, r, mid;
  int val;
} tree[M];
int n, m;
int getint() {
  char ch = getchar();
  int res = 0;
  while (ch < '0' || ch > '9') ch = getchar();
  while ('0' <= ch && ch <= '9') {
    res = res * 10 + ch - '0';
    ch = getchar();
  }
  return res;
}
void MakeTree(int x, int l, int r) {
  tree[x].l = l;
  tree[x].r = r;
  tree[x].val = inf;
  if (l < r) {
    tree[x].mid = (l + r) >> 1;
    tree[x].lson = tree + (x * 2);
    tree[x].rson = tree + (x * 2 + 1);
    MakeTree(x * 2, l, tree[x].mid);
    MakeTree(x * 2 + 1, tree[x].mid + 1, r);
  }
}
int erfen(int x[], int l, int r, int key) {
  int mid = (l + r) >> 1;
  if (x[mid] == key) return mid;
  if (x[mid] < key) return erfen(x, mid + 1, r, key);
  return erfen(x, l, mid - 1, key);
}
void Change(node *x, int l, int r, int key) {
  if (x->l == l && x->r == r)
    x->val = min(x->val, key);
  else if (r <= x->mid)
    Change(x->lson, l, r, key);
  else if (l > x->mid)
    Change(x->rson, l, r, key);
  else {
    Change(x->lson, l, x->mid, key);
    Change(x->rson, x->mid + 1, r, key);
  }
}
void FindDis(node *x, int key) {
  key = min(key, x->val);
  if (x->l == x->r)
    jie[x->l] = key;
  else {
    FindDis(x->lson, key);
    FindDis(x->rson, key);
  }
}
void GetData() {
  int i, j;
  int now;
  n = getint();
  m = getint();
  now = 0;
  for (i = 1; i <= m; i++) {
    xu[i].l = getint();
    xu[i].r = getint();
    xu[i].val = getint();
    lsa[++now] = xu[i].l;
    lsa[++now] = xu[i].r;
  }
  sort(lsa + 1, lsa + now + 1);
  for (i = 1; i <= now; i++) {
    lsa[++lsa[0]] = lsa[i];
    while (i < now && lsa[i] == lsa[i + 1]) i++;
  }
  MakeTree(1, 1, lsa[0] - 1);
  for (i = 1; i <= m; i++) {
    xu[i].l = erfen(lsa, 1, lsa[0], xu[i].l);
    xu[i].r = erfen(lsa, 1, lsa[0], xu[i].r);
    Change(tree + 1, xu[i].l, xu[i].r - 1, xu[i].val);
  }
  for (i = 1; i < lsa[0]; i++) jie[i] = inf;
  FindDis(tree + 1, inf);
  now = 0;
  for (i = 1; i < lsa[0]; i++) {
    if (jie[i] == inf) continue;
    now++;
    xu[now].l = lsa[i];
    while (i < lsa[0] - 1 && jie[i] == jie[i + 1]) i++;
    xu[now].r = lsa[i + 1];
    xu[now].val = jie[i];
  }
  m = now;
  now = 0;
  for (i = 1; i <= m; i++) {
    xu[i].l = xu[i].val - xu[i].l;
    xu[i].r = xu[i].val - xu[i].r;
    swap(xu[i].l, xu[i].r);
    lsb[++now] = xu[i].l;
    lsb[++now] = xu[i].r;
  }
  lsb[++now] = 0;
  sort(lsb + 1, lsb + now + 1);
  for (i = 1; i <= now; i++) {
    lsb[++lsb[0]] = lsb[i];
    while (i < now && lsb[i] == lsb[i + 1]) i++;
  }
  for (i = 1; i <= m; i++) {
    xu[i].l = erfen(lsb, 1, lsb[0], xu[i].l);
    xu[i].r = erfen(lsb, 1, lsb[0], xu[i].r);
    z[xu[i].l]++;
    z[xu[i].r]--;
  }
  for (i = 1; i <= lsb[0]; i++) z[i] += z[i - 1];
}
void Do() {
  int point = 1, has = lsb[1];
  int now;
  int ans = 0;
  while (n--) {
    now = getint();
    while (point < lsb[0] && lsb[point + 1] <= now) {
      ans += (lsb[point + 1] - has) * z[point];
      point++;
      has = lsb[point];
    }
    if (point < lsb[0]) {
      ans += (now - has) * z[point];
      has = now;
    }
    printf("%d\n", ans);
  }
}
int main() {
  GetData();
  Do();
  return 0;
}
