#include <bits/stdc++.h>
using namespace std;
const int DIM = 100005;
const int INF = 1000000009;
long long ans[DIM];
pair<int, int> seg[DIM * 2], evn[DIM * 5];
tuple<int, int, int> asg[DIM];
set<pair<int, int>> axs;
int main(void) {
  ios ::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  int n, m, k = 0;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i)
    cin >> get<1>(asg[i]) >> get<2>(asg[i]) >> get<0>(asg[i]);
  sort(asg + 1, asg + m + 1);
  axs.insert(make_pair(-INF, -INF));
  axs.insert(make_pair(+INF, +INF));
  for (int i = 1; i <= m; ++i) {
    set<pair<int, int>>::iterator bg, en, it;
    bg = prev(axs.lower_bound(make_pair(get<1>(asg[i]), 0)));
    en = axs.upper_bound(make_pair(get<2>(asg[i]), INF));
    if (bg->second < get<1>(asg[i])) ++bg;
    if (bg == en) {
      axs.insert(make_pair(get<1>(asg[i]), get<2>(asg[i])));
      seg[++k] = make_pair(get<0>(asg[i]) - get<2>(asg[i]),
                           get<0>(asg[i]) - get<1>(asg[i]));
      continue;
    }
    if (bg->first > get<1>(asg[i]))
      seg[++k] = make_pair(get<0>(asg[i]) - bg->first,
                           get<0>(asg[i]) - get<1>(asg[i]));
    if (prev(en)->second < get<2>(asg[i]))
      seg[++k] = make_pair(get<0>(asg[i]) - get<2>(asg[i]),
                           get<0>(asg[i]) - prev(en)->second);
    for (it = bg; it != prev(en); ++it) {
      if (it->second == next(it)->first) continue;
      seg[++k] = make_pair(get<0>(asg[i]) - next(it)->first,
                           get<0>(asg[i]) - it->second);
    }
    pair<int, int> aux = make_pair(min(bg->first, get<1>(asg[i])),
                                   max(prev(en)->second, get<2>(asg[i])));
    axs.erase(bg, en);
    axs.insert(aux);
  }
  m = 0;
  for (int i = 1; i <= k; ++i) {
    evn[++m] = make_pair(seg[i].first + INF, 0);
    evn[++m] = make_pair(seg[i].second + INF, -seg[i].first - INF);
  }
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    evn[++m] = make_pair(x + INF, i);
  }
  sort(evn + 1, evn + m + 1);
  long long sum = 0, aux = 0, nr = 0;
  for (int i = 1; i <= m; ++i) {
    if (evn[i].second == 0) aux += evn[i].first, ++nr;
    if (evn[i].second < 0)
      sum += evn[i].first + evn[i].second, aux += evn[i].second, --nr;
    if (evn[i].second > 0) ans[evn[i].second] = sum + nr * evn[i].first - aux;
  }
  for (int i = 1; i <= n; ++i) cout << ans[i] << "\n";
  return 0;
}
