#include <bits/stdc++.h>
using namespace std;
const int INF = 1E9 + 7;
template <class C>
void mini(C& a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C& a4, C b4) {
  a4 = max(a4, b4);
}
int t[100005][3];
vector<pair<int, int> > events;
set<pair<int, int> > miotla;
long long full[100005];
long long part[100005][2];
long long result[100005];
vector<pair<int, int> > tour;
void dodaj(int yd, int yg, int tp) {
  if (0) cout << "DODAJ " << yd << " " << yg << " " << tp << endl;
  int z = tp - yd;
  int idx = upper_bound((tour).begin(), (tour).end(), pair<int, int>(z, INF)) -
            tour.begin();
  full[idx] += yg - yd;
  int z2 = tp - yg;
  int idx2 =
      upper_bound((tour).begin(), (tour).end(), pair<int, int>(z2, INF)) -
      tour.begin();
  if (0) cout << "PAR " << idx2 << " " << idx << " " << yg - tp << endl;
  assert(idx2 <= idx);
  part[idx2][0]++;
  part[idx][0]--;
  part[idx2][1] += yg - tp;
  part[idx][1] -= yg - tp;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = (1); i <= (m); ++i) {
    int yd, yg, tp;
    cin >> yd >> yg >> tp;
    t[i][0] = yd;
    t[i][1] = yg;
    t[i][2] = tp;
    events.push_back(make_pair(yd, i));
    events.push_back(make_pair(yg, -i));
  }
  for (int i = (1); i <= (n); ++i) {
    int q;
    cin >> q;
    tour.push_back(pair<int, int>(q, i));
  }
  sort((events).begin(), (events).end());
  sort((tour).begin(), (tour).end());
  int act = 0;
  while (act < ((int)(events).size())) {
    int next = act;
    while (next < ((int)(events).size()) &&
           events[next].first == events[act].first)
      ++next;
    for (int i = (act); i <= (next - 1); ++i) {
      int kto = abs(events[i].second);
      int val = t[kto][2];
      if (events[i].second > 0)
        miotla.insert(pair<int, int>(val, kto));
      else
        miotla.erase(pair<int, int>(val, kto));
    }
    if (((int)(miotla).size())) {
      int yd, yg;
      yd = events[act].first;
      yg = events[next].first;
      int tim = (*miotla.begin()).first;
      dodaj(yd, yg, tim);
    }
    act = next;
  }
  long long act_sum = 0;
  long long fu = 0;
  int ile = 0;
  for (int i = (0); i <= (n - 1); ++i) {
    int kto = tour[i].second;
    fu += full[i];
    act_sum += part[i][1];
    ile += part[i][0];
    result[kto] = fu + ile * (long long)tour[i].first + act_sum;
  }
  for (int i = (1); i <= (n); ++i) cout << result[i] << endl;
  return 0;
}
