#include <bits/stdc++.h>
using namespace std;
int n, m, a[200100], b[200100], c[200100];
struct event {
  int x, id;
  event(int x = 0, int id = 0) : x(x), id(id) {}
  bool operator<(const event &e) const {
    return x == e.x ? id > e.id : x < e.x;
  }
} e[200100 << 1];
long long ans[200100];
int x[200100], y[200100], z[200100];
int main() {
  scanf("%d %d", &n, &m);
  int tot = 0;
  multiset<int> S;
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
    e[tot++] = event(a[i], i);
    e[tot++] = event(b[i], i);
  }
  sort(e, e + tot);
  m = 0;
  for (int i = 0, j = 0; i < tot; i = j) {
    while (j < tot && e[j].x == e[i].x) {
      int k = e[j].id;
      if (a[k] == e[j].x)
        S.insert(c[k]);
      else
        S.erase(S.find(c[k]));
      j++;
    }
    if (j < tot && !S.empty())
      x[++m] = e[i].x, y[m] = e[j].x, z[m] = *S.begin();
  }
  tot = 0;
  for (int i = 1; i <= m; i++) {
    x[i] = z[i] - x[i] + 1, y[i] = z[i] - y[i];
    swap(x[i], y[i]);
    e[tot++] = event(x[i], i);
    e[tot++] = event(y[i], i);
  }
  for (int i = 1, x; i <= n; i++) scanf("%d", &x), e[tot++] = event(x, -i);
  sort(e, e + tot);
  S.clear();
  long long sum = 0, cur = 0;
  for (int i = 0; i < tot; i++) {
    if (e[i].id < 0) {
      int j = -e[i].id;
      ans[j] = sum + 1ll * e[i].x * S.size() - cur;
    } else {
      int j = e[i].id;
      if (e[i].x == x[j])
        S.insert(x[j]), cur += x[j];
      else
        S.erase(S.find(x[j])), cur -= x[j], sum += y[j] - x[j] - 1;
    }
  }
  for (int i = 1; i <= n; i++) printf("%I64d\n", ans[i]);
  return 0;
}
