#include <bits/stdc++.h>
using namespace std;
pair<int, pair<int, int> > tup[100000 * 2 + 10];
multiset<int> st;
int L[100000 * 2 + 10], R[100000 * 2 + 10], sl[100000 * 2 + 10],
    sr[100000 * 2 + 10];
int main() {
  int m, n, r, l, t;
  scanf("%d%d", &m, &n);
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &l, &r, &t);
    tup[i] = make_pair(l, make_pair(t, 0));
    tup[i + n] = make_pair(r, make_pair(t, 1));
  }
  n *= 2;
  sort(tup + 1, tup + n + 1);
  int lasty = -1, o = 0;
  for (int i = 1; i <= n; i++) {
    int cury = tup[i].first;
    if (lasty != -1 && cury != lasty && st.size()) {
      if (st.empty()) {
        printf("empty\n");
        return 0;
      }
      int curt = *st.begin();
      L[++o] = curt - lasty;
      R[o] = curt - cury;
    }
    lasty = cury;
    if (tup[i].second.second)
      st.erase(st.lower_bound(tup[i].second.first));
    else
      st.insert(tup[i].second.first);
  }
  if (flag) {
    printf("o:%d\n", o);
    return 0;
  }
  sort(L + 1, L + o + 1);
  sort(R + 1, R + o + 1);
  for (int i = 1; i <= o; i++)
    sl[i] = sl[i - 1] + L[i], sr[i] = sr[i - 1] + R[i];
  while (m--) {
    scanf("%d", &t);
    l = lower_bound(L + 1, L + o + 1, t) - L - 1;
    r = lower_bound(R + 1, R + o + 1, t) - R - 1;
    printf("%d\n", (int)((r - l) * (long long)t - sr[r] + sl[l]));
  }
  return 0;
}
