#include <bits/stdc++.h>
using namespace std;
inline int Get() {
  int res = 0, q = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') q = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') res = res * 10 + ch - '0', ch = getchar();
  return res * q;
}
const double eps = 1e-12, pi = M_PI;
const int oo = (int)2e9, mod = (int)1e9 + 7;
const long long INF = (long long)1e17;
const int N = (int)2e5;
set<pair<int, int> > st;
int n, m, top;
pair<int, int> ad[N + 10];
set<pair<int, int> >::iterator S, T, V, A[N + 10];
struct node {
  int l, r, t;
} w[N + 10];
struct query {
  int t, tp;
} q[5 * N + 10];
bool cmp(const node &a, const node &b) { return a.t < b.t; }
bool cmp_q(const query &a, const query &b) {
  return (a.t < b.t) || (a.t == b.t && a.tp < b.tp);
}
int main() {
  scanf(
      "%d"
      "%d"
      "\n",
      &n, &m);
  for (int i = (1), end = (m); i <= end; ++i)
    scanf(
        "%d"
        "%d"
        "%d"
        "\n",
        &w[i].l, &w[i].r, &w[i].t),
        --w[i].r;
  sort(w + 1, w + m + 1, cmp);
  st.insert(make_pair(0, oo >> 1));
  int cnt = 0;
  for (int i = (1), end = (m); i <= end; ++i) {
    S = st.upper_bound(make_pair(w[i].l, oo));
    if (S != st.begin()) --S;
    T = st.upper_bound(make_pair(w[i].r, oo));
    int all = 0, det = 0;
    for (V = S; V != T; ++V) {
      if (V == st.end()) break;
      pair<int, int> now = *V;
      if (now.first >= w[i].l && now.second <= w[i].r) {
        q[++cnt] = (query){w[i].t - now.second, 0};
        q[++cnt] = (query){w[i].t - now.first, 2};
        A[++det] = V;
      } else if (now.first < w[i].l && now.second > w[i].r) {
        q[++cnt] = (query){w[i].t - w[i].r, 0};
        q[++cnt] = (query){w[i].t - w[i].l, 2};
        A[++det] = V;
        ad[++all] = make_pair(now.first, w[i].l - 1),
        ad[++all] = make_pair(w[i].r + 1, now.second);
      } else if (now.first < w[i].l && now.second >= w[i].l) {
        q[++cnt] = (query){w[i].t - now.second, 0};
        q[++cnt] = (query){w[i].t - w[i].l, 2};
        A[++det] = V;
        ad[++all] = make_pair(now.first, w[i].l - 1);
      } else if (now.first <= w[i].r && now.second > w[i].r) {
        q[++cnt] = (query){w[i].t - w[i].r, 0};
        q[++cnt] = (query){w[i].t - now.first, 2};
        A[++det] = V;
        ad[++all] = make_pair(w[i].r + 1, now.second);
      }
    }
    for (int i = (1), end = (det); i <= end; ++i) st.erase(A[i]);
    for (int i = (1), end = (all); i <= end; ++i) st.insert(ad[i]);
  }
  for (int i = (1), end = (n); i <= end; ++i)
    scanf("%d", &q[++cnt].t), q[cnt].tp = 1;
  sort(q + 1, q + cnt + 1, cmp_q);
  int tot = 0, l = 0, ls = q[1].t;
  for (int i = (1), end = (cnt); i <= end; ++i) {
    if (q[i].tp == 1)
      printf(
          "%d"
          "\n",
          l + tot * (q[i].t - ls + 1));
    else {
      if (!q[i].tp)
        l += (q[i].t - ls) * tot, ls = q[i].t, ++tot;
      else
        l += (q[i].t - ls + 1) * tot, ls = q[i].t + 1, --tot;
    }
  }
  return 0;
}
