#include <bits/stdc++.h>
using namespace std;
int N, M;
signed long long L[100020], R[100020], T[100020];
signed long long Q[100020];
vector<pair<signed long long, signed long long> > QP;
signed long long PP[200200];
signed long long AS[200200], BS[200200], ret[200200];
vector<signed long long> S[200200], E[200200];
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N >> M;
  for (i = 0; i < M; i++) cin >> L[i] >> R[i] >> T[i];
  for (i = 0; i < N; i++) cin >> Q[i], QP.push_back(make_pair(Q[i], i));
  sort(QP.begin(), QP.end());
  map<signed long long, signed long long> UM;
  UM[0] = 0;
  for (i = 0; i < M; i++) UM[L[i]] = UM[R[i]] = 1;
  i = 0;
  for (__typeof(UM.begin()) it = UM.begin(); it != UM.end(); it++)
    it->second = i++, PP[it->second] = it->first;
  for (i = 0; i < M; i++)
    S[UM[L[i]]].push_back(T[i]), E[UM[R[i]]].push_back(T[i]);
  map<signed long long, int> CS;
  for (i = 0; i < UM.size(); i++) {
    for (j = 0; j < E[i].size(); j++)
      if (--CS[E[i][j]] == 0) CS.erase(E[i][j]);
    for (j = 0; j < S[i].size(); j++) CS[S[i][j]]++;
    if (CS.size()) {
      signed long long ct = CS.begin()->first;
      x = lower_bound(QP.begin(), QP.end(), make_pair(ct - PP[i + 1], 0LL)) -
          QP.begin();
      y = lower_bound(QP.begin(), QP.end(), make_pair(ct - PP[i], 0LL)) -
          QP.begin();
      AS[x]++;
      AS[y]--;
      BS[x] -= ct - PP[i + 1], BS[y] += ct - PP[i];
    }
  }
  signed long long aa = 0, bb = 0;
  for (i = 0; i < N; i++)
    aa += AS[i], bb += BS[i], ret[QP[i].second] = aa * QP[i].first + bb;
  for (i = 0; i < N; i++) cout << ret[i] << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false);
  for (i = 0; i < argc - 1; i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < s.size(); i++) ungetc(s[s.size() - 1 - i], stdin);
  solve();
  return 0;
}
