#include <bits/stdc++.h>
using namespace std;
long long fpm(long long b, long long e, long long m) {
  long long t = 1;
  for (; e; e >>= 1, b = b * b % m) e & 1 ? t = t * b % m : 0;
  return t;
}
template <class T>
inline bool chkmin(T &a, T b) {
  return a > b ? a = b, true : false;
}
template <class T>
inline bool chkmax(T &a, T b) {
  return a < b ? a = b, true : false;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <typename T>
T gcd(T x, T y) {
  for (T t; x; t = x, x = y % x, y = t)
    ;
  return y;
}
template <class edge>
struct Graph {
  vector<vector<edge> > adj;
  Graph(int n) {
    adj.clear();
    adj.resize(n + 5);
  }
  Graph() { adj.clear(); }
  void resize(int n) { adj.resize(n + 5); }
  void add(int s, edge e) { adj[s].push_back(e); }
  void del(int s, edge e) { adj[s].erase(find(iter(adj[s]), e)); }
  vector<edge> &operator[](int t) { return adj[t]; }
};
struct event {
  int time, coef, cnst;
};
const int maxn = 220000;
int ufs[maxn], rep[maxn], l[maxn], r[maxn], t[maxn], perm[maxn];
vector<int> v;
int discrete(int x) {
  return upper_bound((v).begin(), (v).end(), x) - v.begin();
}
int cmp(const int &a, const int &b) { return t[a] < t[b]; }
int cmp_evt(const event &a, const event &b) { return a.time < b.time; }
int find(int t) { return ufs[t] ? ufs[t] = find(ufs[t]) : t; }
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> l[i] >> r[i] >> t[i];
    v.push_back(l[i]);
    v.push_back(r[i]);
    perm[i] = i;
  }
  sort((v).begin(), (v).end()),
      v.resize(unique((v).begin(), (v).end()) - v.begin());
  sort(perm + 1, perm + m + 1, cmp);
  vector<event> Q;
  for (int i = 1; i <= m; ++i) {
    int L = discrete(l[perm[i]]), R = find(discrete(r[perm[i]])),
        T = t[perm[i]];
    for (; L = find(L), L != R; ++L) {
      Q.push_back((event){T - v[L], +1, v[L] - T});
      Q.push_back((event){T - v[L - 1], -1, T - v[L - 1]});
      ufs[L] = find(L + 1);
    }
  }
  sort((Q).begin(), (Q).end(), cmp_evt);
  int coef = 0, cnst = 0;
  vector<event>::iterator it = Q.begin();
  for (int i = 1, q; i <= n; ++i) {
    cin >> q;
    for (; it != Q.end() && it->time <= q; ++it) {
      coef += it->coef;
      cnst += it->cnst;
    }
    cout << cnst + coef * q << endl;
  }
  return 0;
}
