#include <bits/stdc++.h>
using namespace std;
const int NS = 100010;
struct Node {
  int d, t, f;
  Node() {}
  Node(int a, int b, int c) : d(a), t(b), f(c) {}
  bool operator<(const Node cmp) const { return d < cmp.d; }
} L[NS << 1];
struct NOde {
  int d, t, f;
  NOde() {}
  NOde(int a, int b, int c) : d(a), t(b), f(c) {}
  bool operator<(const NOde cmp) const { return t < cmp.t; }
} X[NS << 2];
int n, m, l, r, d, f, t, p, top, ans, cnt;
multiset<int> myset;
bool cmp1(Node a1, Node a2) {
  if (a1.d != a2.d) return a1.d < a2.d;
  return a1.f > a2.f;
}
bool cmp2(Node a1, Node a2) {
  if (a1.t != a2.t) return a1.t < a2.t;
  return a1.f > a2.f;
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    top = 0;
    for (int i = 0; i < m; i++) {
      scanf("%d%d%d", &l, &r, &t);
      L[i + i] = Node(l, t, 1);
      L[i + i + 1] = Node(r, t, -1);
    }
    m = m + m;
    sort(L, L + m);
    for (int i = 0; i < m; i++) {
      d = L[i].d, t = L[i].t, f = L[i].f;
      if (!myset.empty()) {
        X[top++] = NOde(l, *myset.begin() - p, 1);
        X[top++] = NOde(r, *myset.begin() - d, -1);
      }
      p = d;
      if (f > 0)
        myset.insert(t);
      else
        myset.erase(myset.find(t));
    }
    sort(X, X + top);
    ans = cnt = 0;
    for (int i = 0, j = 0; i < n; i++) {
      scanf("%d", &t);
      for (; j < top && X[j].t <= t; j++) {
        if (X[j].f < 0) {
          cnt++;
          ans -= X[j].t;
        } else {
          cnt--;
          ans += X[j].t;
        }
      }
      printf("%d\n", ans + t * cnt);
    }
  }
  return 0;
}
