#include <bits/stdc++.h>
using namespace std;
void Get(int &T) {
  char C;
  bool F = 0;
  for (; C = getchar(), C < '0' || C > '9';)
    if (C == '-') F = 1;
  for (T = C - '0'; C = getchar(), C >= '0' && C <= '9'; T = T * 10 + C - '0')
    ;
  F && (T = -T);
}
int N, M;
int Q[1000005];
int L[1000005];
int R[1000005];
int Time[1000005];
int Order[1000005];
int T[1000005];
int X[1000005];
int K[1000005];
int Top;
bool Cmp(int X, int Y) { return Time[X] < Time[Y]; }
bool Cmp2(int X, int Y) { return T[X] < T[Y]; }
void Init() {
  Get(N);
  Get(M);
  for (int i = 1; i <= M; i++) {
    Get(L[i]);
    Get(R[i]);
    Get(Time[i]);
    Order[i] = i;
  }
  for (int i = 1; i <= N; i++) Get(Q[i]);
  std::sort(Order + 1, Order + M + 1, Cmp);
}
set<pair<int, int> > Set;
void Insert(int L, int R, int Time) {
  typeof(Set.begin()) k = Set.upper_bound(make_pair(R + 1, 0)), p;
  if (k != Set.begin()) {
    k--;
    for (;;) {
      if (k->first <= R && L <= k->second) {
        L = std::min(L, k->first);
        R = std::max(R, k->second);
        Top++;
        T[Top] = Time - k->second;
        X[Top] = k->second;
        K[Top] = -1;
        Top++;
        T[Top] = Time - k->first;
        X[Top] = k->first;
        K[Top] = 1;
        p = k;
        if (k == Set.begin()) {
          Set.erase(p);
          break;
        } else {
          k--;
          Set.erase(p);
        }
      } else
        break;
    }
  }
  pair<int, int> S = make_pair(L, R);
  Set.insert(S);
  Top++;
  T[Top] = Time - R;
  X[Top] = R;
  K[Top] = 1;
  Top++;
  T[Top] = Time - L;
  X[Top] = L;
  K[Top] = -1;
}
void Debug() {
  for (typeof(Set.begin()) k = Set.begin(); k != Set.end(); k++)
    printf("[ %d , %d ]   ", k->first, k->second);
  puts("");
  for (int i = 1; i <= M; i++) printf("%d\n", Order[i]);
}
void Debug2() {
  for (int L, R;;) {
    Get(L);
    Get(R);
    Insert(L, R, 0);
    Debug();
  }
}
long long Cnt;
long long Ans[1000005];
long long B;
void Work() {
  for (int k = 1, i; k <= M; k++) {
    i = Order[k];
    Insert(L[i], R[i], Time[i]);
  }
  Top++;
  T[Top] = 0x3f3f3f3f;
  for (int k = 1; k <= Top; k++) Order[k] = k;
  std::sort(Order + 1, Order + Top + 1, Cmp2);
  for (int k = 1, i, j = 1; k <= Top; k++) {
    i = Order[k];
    for (; j <= N; j++) {
      if (T[i] > Q[j]) {
        Ans[j] = Cnt * Q[j] + B;
      } else
        break;
    }
    Cnt += K[i];
    B -= K[i] * (long long)T[i];
  }
}
void Output() {
  for (int i = 1; i <= N; i++) printf("%I64d\n", Ans[i]);
}
int main() {
  Init();
  Work();
  Output();
  return 0;
}
