#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 400007;
struct qT {
  void setd(int _p, int _t) { p = _p, t = _t; }
  bool operator<(const qT &a) const { return (p < a.p); }
  int p, t;
} ad[MAXN], rm[MAXN];
struct eT {
  void setd(int _tp, int _t) { tp = _tp, t = _t; }
  bool operator<(const eT &a) const { return (t < a.t); }
  int tp, t;
} ev[MAXN];
int n, m;
int l[MAXN], r[MAXN], t[MAXN];
int mt[MAXN];
int q[MAXN];
map<int, int> bts;
int stb[MAXN];
void init();
void input();
void work();
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) scanf("%d%d%d", &l[i], &r[i], &t[i]);
  for (int i = 0; i < n; ++i) scanf("%d", &q[i]);
}
void work() {
  for (int i = 0; i < m; ++i) bts[l[i]] = 0, bts[r[i]] = 0;
  int kk = 0;
  for (map<int, int>::iterator it = bts.begin(); it != bts.end(); ++it) {
    it->second = kk, stb[kk] = it->first;
    ++kk;
  }
  for (int i = 0; i < m; ++i) {
    l[i] = bts[l[i]], r[i] = bts[r[i]];
    ad[i].setd(l[i], t[i]);
    rm[i].setd(r[i], t[i]);
  }
  sort(ad, ad + m);
  sort(rm, rm + m);
  multiset<int> s;
  s.insert(INF);
  int iad = 0, irm = 0;
  for (int i = 0; i < kk; ++i) {
    while (ad[iad].p == i) s.insert(ad[iad++].t);
    while (rm[irm].p == i) s.erase(s.find(rm[irm++].t));
    mt[i] = *s.begin();
  }
  int ke = 0;
  for (int i = 0; i < kk; ++i) {
    if (mt[i] ^ INF) {
      ev[ke++].setd(1, mt[i] - stb[i + 1]), ev[ke++].setd(-1, mt[i] - stb[i]);
    }
  }
  sort(ev, ev + ke);
  int nk = 0, lt = -INF, del = 0;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (; nk < ke && ev[nk].t <= q[i]; ++nk)
      ans += (ev[nk].t - lt) * del, lt = ev[nk].t, del += ev[nk].tp;
    printf("%d\n", ans + del * (q[i] - lt));
  }
}
