#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
inline void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const int maxn = 100000 + 5;
int n, m;
int L[maxn], R[maxn], T[maxn];
int q[maxn], ret[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin >> m >> n;
  for (int i = 0; i < n; i++) cin >> L[i] >> R[i] >> T[i];
  for (int i = 0; i < m; i++) cin >> q[i];
  vector<pair<int, int> > events;
  for (int i = 0; i < n; i++) {
    events.push_back(make_pair(L[i], i));
    events.push_back(make_pair(R[i], i));
  }
  set<pair<int, int> > S;
  int last = 0;
  sort(events.begin(), events.end());
  vector<pair<int, int> > update1, update2;
  for (int i = 0; i < ((int)events.size()); i++) {
    if (last != events[i].first && ((int)S.size()) > 0) {
      int next = events[i].first;
      int key = S.begin()->first;
      update1.push_back(make_pair(key - last, key - last));
      update2.push_back(make_pair(key - next, 1));
      update2.push_back(make_pair(key - last, -1));
      update1.push_back(make_pair(key - next, -(key - next)));
    }
    last = events[i].first;
    int idx = events[i].second;
    if (last == L[idx])
      S.insert(make_pair(T[idx], idx));
    else
      S.erase(make_pair(T[idx], idx));
  }
  vector<pair<int, int> > order;
  for (int i = 0; i < m; i++) order.push_back(make_pair(q[i], i));
  sort(order.begin(), order.end());
  sort(update1.begin(), update1.end());
  sort(update2.begin(), update2.end());
  long long d1 = 0, d2 = 0;
  int p1 = 0, p2 = 0;
  for (int i = 0; i < m; i++) {
    int key = order[i].first;
    for (; p1 < ((int)update1.size()) && update1[p1].first <= key; p1++)
      d1 += update1[p1].second;
    for (; p2 < ((int)update2.size()) && update2[p2].first <= key; p2++)
      d2 += update2[p2].second;
    ret[order[i].second] = (int)(d1 + d2 * key);
  }
  for (int i = 0; i < m; i++) printf("%d\n", ret[i]);
  return 0;
}
