#include <bits/stdc++.h>
using namespace std;
const int NMax = 110000;
vector<pair<pair<int, int>, int> > LSH, T;
multiset<int> state;
int N, M, Ans[NMax];
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= M; i++) {
    int first, second, z;
    scanf("%d%d%d", &first, &second, &z);
    LSH.push_back(make_pair(make_pair(first, z), 1));
    LSH.push_back(make_pair(make_pair(second, z), 0));
  }
  sort(LSH.begin(), LSH.end());
  for (int i = 0; i < LSH.size(); i++) {
    if (i > 0 && !state.empty()) {
      multiset<int>::iterator p = state.begin();
      int t = (*p);
      T.push_back(make_pair(make_pair(t - LSH[i].first.first, 1), -1));
      T.push_back(make_pair(make_pair(t - LSH[i - 1].first.first, 0), -1));
    }
    if (LSH[i].second == 1)
      state.insert(LSH[i].first.second);
    else
      state.erase(state.find(LSH[i].first.second));
  }
  for (int i = 1; i <= N; i++) {
    int first;
    scanf("%d", &first);
    T.push_back(make_pair(make_pair(first, -1), i));
  }
  sort(T.begin(), T.end());
  int cnt = 0, sum = 0;
  for (int i = 0; i < T.size(); i++) {
    if (cnt) sum += cnt * (T[i].first.first - T[i - 1].first.first);
    if (T[i].first.second == 1)
      cnt++;
    else if (T[i].first.second == 0)
      cnt--;
    else
      Ans[T[i].second] = sum;
  }
  for (int i = 1; i <= N; i++) printf("%d\n", Ans[i]);
  getchar();
  getchar();
  return 0;
}
