#include <bits/stdc++.h>
using namespace std;
multiset<int> Hash;
struct line {
  int x, t;
  bool tp;
  line() {}
  line(int _x, int _t, bool _tp) : x(_x), t(_t), tp(_tp) {}
  bool operator<(const line &a) const { return x < a.x; }
} L[200000];
pair<int, bool> l2[400000];
int main() {
  int n, m, l, r, t, l_sz = 0, l2_sz = 0;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &l, &r, &t);
    L[l_sz++] = line(l, t, 0);
    L[l_sz++] = line(r, t, 1);
  }
  sort(L, L + l_sz);
  for (int i = 0; i < l_sz; i++) {
    if (i != 0 && L[i].x != L[i - 1].x && !Hash.empty()) {
      int t = *Hash.begin();
      l2[l2_sz++] = make_pair(t - L[i].x, 0);
      l2[l2_sz++] = make_pair(t - L[i - 1].x, 1);
    }
    if (L[i].tp == 0)
      Hash.insert(L[i].t);
    else
      Hash.erase(Hash.find(L[i].t));
  }
  long long a_sz = 0, b_sz = 0, a_sum = 0, b_sum = 0;
  sort(l2, l2 + l2_sz);
  int q, j = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &q);
    for (; j < l2_sz && l2[j].first < q; j++) {
      if (l2[j].second == 0) {
        a_sum += l2[j].first;
        a_sz++;
      } else {
        b_sum += l2[j].first;
        b_sz++;
      }
    }
    printf("%I64d\n", a_sz * q - a_sum - (b_sz * q - b_sum));
  }
}
