#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, int> > wa;
vector<int> t;
vector<int> q;
vector<int> p;
int t1, t2, t3;
set<pair<int, int> > st;
vector<pair<int, int> > vec;
vector<int> tv;
int sum;
int sp;
vector<pair<int, int> > qt;
vector<int> ans;
bool cmp(int a, int b) { return t[a] < t[b]; }
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> t1 >> t2 >> t3;
    wa.push_back(pair<int, int>(t1, t2));
    t.push_back(t3);
    p.push_back(i);
  }
  sort((p).begin(), (p).end(), cmp);
  for (int i = 0; i < m; ++i) {
    int b = wa[p[i]].first, e = wa[p[i]].second;
    int le = b;
    set<pair<int, int> >::iterator it =
        st.lower_bound(pair<int, int>(wa[p[i]].first, -1));
    while (it != st.end() && it->second <= wa[p[i]].second) {
      int en = it->second;
      if (le < en) {
        vec.push_back(pair<int, int>(le, en));
        tv.push_back(t[p[i]]);
      }
      le = it->first;
      b = min(b, it->second);
      e = max(e, it->first);
      typeof(it) it2 = it;
      it++;
      st.erase(it2);
    }
    if (wa[p[i]].second > le) {
      vec.push_back(pair<int, int>(le, wa[p[i]].second));
      tv.push_back(t[p[i]]);
    }
    st.insert(pair<int, int>(e, b));
  }
  for (int i = 0; i < n; ++i) {
    cin >> t1;
    q.push_back(t1);
    qt.push_back(pair<int, int>(t1, 0));
  }
  for (int i = 0; i < (int)(tv).size(); ++i)
    qt.push_back(pair<int, int>(tv[i] - vec[i].second, 1));
  for (int i = 0; i < (int)(tv).size(); ++i)
    qt.push_back(pair<int, int>(tv[i] - vec[i].first, 2));
  sort((qt).begin(), (qt).end());
  int curt = 0;
  for (int i = 0; i < (int)(qt).size(); ++i) {
    sum += sp * (qt[i].first - curt);
    curt = qt[i].first;
    if (qt[i].second == 0) cout << sum << endl;
    if (qt[i].second == 1) sp++;
    if (qt[i].second == 2) sp--;
  }
  return 0;
}
