#include <bits/stdc++.h>
using namespace std;
long long sqr(long long x) { return x * x; }
template <class T>
void checkmax(T &t, T x) {
  if (x > t) t = x;
}
template <class T>
void checkmin(T &t, T x) {
  if (x < t) t = x;
}
template <class T>
void _checkmax(T &t, T x) {
  if (t == -1 || x > t) t = x;
}
template <class T>
void _checkmin(T &t, T x) {
  if (t == -1 || x < t) t = x;
}
long long power_mod(long long a, int b, int p) {
  long long ret = 1;
  for (; b; b >>= 1) {
    if (b & 1) ret = ret * a % p;
    a = a * a % p;
  }
  return ret;
}
const int N = 100005 * 2;
int n, m;
struct triple {
  int l, r, t;
  triple() { l = r = t = 0; }
  triple(int l, int r, int t) : l(l), r(r), t(t) {}
} seg[N];
set<pair<int, int> > s[3];
void init() {
  set<int> coor;
  for (int i = 0; i < (int)(m); i++) {
    coor.insert(seg[i].l);
    coor.insert(seg[i].r);
  }
  vector<int> c = vector<int>(coor.begin(), coor.end());
  vector<vector<int> > st = vector<vector<int> >(c.size(), vector<int>());
  vector<vector<int> > ed = vector<vector<int> >(c.size(), vector<int>());
  for (int i = 0; i < (int)(m); i++) {
    st[lower_bound(c.begin(), c.end(), seg[i].l) - c.begin()].push_back(i);
    ed[lower_bound(c.begin(), c.end(), seg[i].r) - c.begin()].push_back(i);
  }
  set<pair<int, int> > s;
  vector<triple> res;
  for (int i = 0; i < (int)(c.size()); i++) {
    for (__typeof((st[i]).begin()) it = (st[i]).begin(); it != (st[i]).end();
         it++)
      s.insert(make_pair(seg[*it].t, *it));
    for (__typeof((ed[i]).begin()) it = (ed[i]).begin(); it != (ed[i]).end();
         it++)
      s.erase(make_pair(seg[*it].t, *it));
    if (!s.empty()) res.push_back(triple(c[i], c[i + 1], s.begin()->first));
  }
  m = res.size();
  for (int i = 0; i < (int)(m); i++) seg[i] = res[i];
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < (int)(m); i++) {
    cin >> seg[i].l >> seg[i].r >> seg[i].t;
  }
  init();
  for (int i = 0; i < (int)(m); i++) {
    s[2].insert(make_pair(seg[i].t - seg[i].r, i));
  }
  long long sum[2] = {0, 0};
  for (int i = 0; i < (int)(n); i++) {
    int t;
    cin >> t;
    while (!s[2].empty() && s[2].begin()->first <= t) {
      int j = s[2].begin()->second;
      s[2].erase(s[2].begin());
      s[1].insert(make_pair(seg[j].t - seg[j].l, j));
      sum[1] += seg[j].r - seg[j].t;
    }
    while (!s[1].empty() && s[1].begin()->first <= t) {
      int j = s[1].begin()->second;
      s[1].erase(s[1].begin());
      sum[1] -= seg[j].r - seg[j].t;
      sum[0] += seg[j].r - seg[j].l;
    }
    long long ans = sum[0] + sum[1] + t * s[1].size();
    cout << ans << endl;
  }
  return 0;
}
