#include <bits/stdc++.h>
template <typename Tp>
void in(Tp &x) {
  char ch = getchar(), f = 1;
  x = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') f = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
template <typename Tp>
Tp chkmax(Tp &x, Tp y) {
  return x > y ? x : x = y;
}
template <typename Tp>
Tp chkmin(Tp &x, Tp y) {
  return x < y ? x : x = y;
}
template <typename Tp>
Tp Max(Tp x, Tp y) {
  return x > y ? x : y;
}
template <typename Tp>
Tp Min(Tp x, Tp y) {
  return x < y ? x : y;
}
using std::make_pair;
using std::pair;
using std::priority_queue;
using std::vector;
const int MAXN = 1000010;
int n, m;
int p[MAXN];
pair<int, int> inter[MAXN << 1], two[MAXN * 3];
bool del[MAXN];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               std::greater<pair<int, int> > >
    q;
int tot, tot2;
void add(int x, int y) {
  int L = inter[x].first, R = inter[y].first;
  if (q.empty()) return;
  int t = q.top().second;
  while (del[t]) {
    q.pop();
    if (q.empty()) return;
    t = q.top().second;
  }
  t = p[t];
  R--;
  two[++tot2] = make_pair(t - R, 0);
  two[++tot2] = make_pair(t - L, 1000000003 + t - R);
}
int main() {
  in(n);
  in(m);
  for (int i = (1), i_END_ = (m); i <= i_END_; i++) {
    int l, r;
    in(l);
    in(r);
    in(p[i]);
    inter[++tot] = make_pair(l, i);
    inter[++tot] = make_pair(r, -i);
  }
  std::sort(inter + 1, inter + tot + 1);
  for (int i = (1), i_END_ = (tot); i <= i_END_; i++) {
    if (i != 1 && inter[i - 1].first < inter[i].first) add(i - 1, i);
    if (inter[i].second > 0)
      q.push(make_pair(p[inter[i].second], inter[i].second));
    else
      del[-inter[i].second] = true;
  }
  for (int i = (1), i_END_ = (n); i <= i_END_; i++) {
    int t;
    in(t);
    two[++tot2] = make_pair(t, 1);
  }
  int k = 0, b = 0;
  std::sort(two + 1, two + tot2 + 1);
  for (int i = (1), i_END_ = (tot2); i <= i_END_; i++) {
    pair<int, int> now = two[i];
    if (!two[i].second) {
      k++;
      b += 1 - two[i].first;
    } else if (two[i].second >= 2) {
      int x = two[i].second - 1000000003;
      k--;
      b -= 1 - x;
      b += two[i].first - x + 1;
    } else {
      printf("%d\n", k * two[i].first + b);
    }
  }
  return 0;
}
