#include <bits/stdc++.h>
using namespace std;
class node {
 public:
  int ch[2];
  long long a0, d;
};
class segment_tree {
 public:
  node t[100010 * 64];
  int nodecnt;
  void pushnow(int p, long long a0, long long d) {
    t[p].a0 += a0;
    t[p].d += d;
  }
  void pushdown(int p, int l, int r) {
    if (!t[p].ch[0]) t[p].ch[0] = ++nodecnt;
    if (!t[p].ch[1]) t[p].ch[1] = ++nodecnt;
    if (t[p].a0 || t[p].d) {
      long long mid = (l + r) >> 1;
      pushnow(t[p].ch[0], t[p].a0, t[p].d);
      pushnow(t[p].ch[1], t[p].a0 + (mid - l + 1) * t[p].d, t[p].d);
      t[p].a0 = 0;
      t[p].d = 0;
    }
  }
  void modify(int &p, int l, int r, int ml, int mr, long long a0, long long d) {
    if (!p) p = ++nodecnt;
    if (ml <= l && r <= mr) {
      pushnow(p, a0 + (l - ml) * d, d);
      return;
    }
    pushdown(p, l, r);
    long long mid = (l + r) >> 1;
    if (ml <= mid) modify(t[p].ch[0], l, mid, ml, mr, a0, d);
    if (mr > mid) modify(t[p].ch[1], mid + 1, r, ml, mr, a0, d);
  }
  long long query(int p, int l, int r, int pos) {
    if (l == r) return t[p].a0;
    pushdown(p, l, r);
    long long mid = (l + r) >> 1;
    if (pos <= mid)
      return query(t[p].ch[0], l, mid, pos);
    else
      return query(t[p].ch[1], mid + 1, r, pos);
  }
} T;
int n, m, l, r, t, rt, LL[500010], rr[500010], tt[500010];
vector<pair<pair<int, int>, int> > v;
int comp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  if (a.first.first != b.first.first) return a.first.first < b.first.first;
  if (a.second != b.second) return a.second > b.second;
  return a.first.second < b.first.second;
}
multiset<int> st;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &l, &r, &t);
    r--;
    v.push_back(make_pair(make_pair(l, t), 1));
    v.push_back(make_pair(make_pair(r, t), -1));
  }
  sort(v.begin(), v.end(), comp);
  int pre, cnt = 0;
  for (int i = 0; i < v.size(); i++) {
    int l = v[i].first.first, t = v[i].first.second, fg = v[i].second;
    if (st.size() == 0) {
      pre = l;
      st.insert(t);
      continue;
    }
    if (l > pre) {
      LL[cnt] = pre;
      rr[cnt] = l - 1;
      tt[cnt] = *st.begin();
      cnt++;
      pre = l;
    }
    if (fg == -1) {
      if (pre == l) {
        LL[cnt] = pre;
        rr[cnt] = l;
        tt[cnt] = *st.begin();
        cnt++;
        pre = l + 1;
      }
      st.erase(st.lower_bound(t));
    } else
      st.insert(t);
  }
  for (int i = 0, L, R; i < cnt; i++) {
    l = LL[i], r = rr[i], t = tt[i];
    L = max(0, t - l + 1);
    R = 1000000000;
    if (L <= R) T.modify(rt, 0, 1000000000, L, R, r - l + 1, 0);
    L = t - r;
    R = t - l;
    if (R >= 0) T.modify(rt, 0, 1000000000, L, R, 1, 1);
  }
  for (int i = 1, ti; i <= n; i++) {
    scanf("%d", &ti);
    printf("%lld\n", T.query(rt, 0, 1000000000, ti));
  }
  return 0;
}
