#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > v;
vector<pair<pair<int, int>, int> > t;
int n, m;
multiset<int> s;
multiset<pair<int, int> > zac;
multiset<int> kon;
int wyn = 0;
int dod = 0;
int odo = 0;
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    v.push_back(make_pair(make_pair(a, -1), c));
    v.push_back(make_pair(make_pair(b, 1), c));
  }
  sort(v.begin(), v.end());
  int l = 1e9 + 5;
  for (int i = 0; i < v.size(); i++) {
    if (!s.empty() && (v[i].first.first > l))
      t.push_back(make_pair(make_pair(l, v[i].first.first), *s.begin()));
    if (v[i].first.second < 0)
      s.insert(v[i].second);
    else
      s.erase(s.find(v[i].second));
    l = v[i].first.first;
  }
  for (int i = 0; i < t.size(); i++) {
    zac.insert(make_pair(t[i].second - t[i].first.second,
                         t[i].first.second - t[i].first.first));
  }
  l = 0;
  while (n--) {
    int x;
    scanf("%d", &x);
    int uuu = x;
    x -= l;
    l = uuu;
    odo += x;
    dod += x;
    wyn += kon.size() * x;
    while (!zac.empty()) {
      pair<int, int> p = (*zac.begin());
      if (p.first <= odo) {
        kon.insert(p.second + p.first - odo + dod);
        wyn += odo - p.first;
        zac.erase(zac.begin());
      } else
        break;
    }
    while (!kon.empty()) {
      int p = (*kon.begin());
      if (p <= dod) {
        wyn += p - dod;
        kon.erase(kon.begin());
      } else
        break;
    }
    printf("%d\n", wyn);
  }
  return 0;
}
