#include <bits/stdc++.h>
char ch;
inline void read(int &x) {
  x = 0;
  ch = getchar();
  while (ch <= 32) ch = getchar();
  while (ch > 32) {
    x = x * 10 + ch - 48;
    ch = getchar();
  };
};
inline int min(int a, int b) { return a < b ? a : b; }
int n, m;
struct data {
  int l, r, t;
};
inline bool operator<(data a, data b) { return a.t > b.t; };
data a[100005];
int _tmp[100005 * 2];
struct segnode {
  segnode *l, *r;
  int x;
} _seg[100005 * 2 * 2], *stot = _seg;
inline segnode *build(int n) {
  segnode *ret = ++stot;
  ret->x = 1100000000;
  if (n > 1) {
    int mid = n >> 1;
    ret->l = build(mid);
    ret->r = build(n - mid);
  };
  return ret;
};
inline void cover(segnode *a, int l, int r, int x, int n) {
  if (l == 1 && r == n) {
    a->x = x;
    return;
  };
  int mid = n >> 1;
  if (r <= mid) {
    cover(a->l, l, r, x, mid);
  } else if (l > mid) {
    cover(a->r, l - mid, r - mid, x, n - mid);
  } else {
    cover(a->l, l, mid, x, mid);
    cover(a->r, 1, r - mid, x, n - mid);
  };
};
struct event {
  int t, dk, db;
} e[100005 * 2 * 2];
inline bool operator<(event a, event b) { return a.t < b.t; };
int ecnt;
inline void add_event(int t, int dk, int db) {
  e[++ecnt] = (event){t, dk, db};
};
inline void add_seg(int t, int l, int r) {
  add_event(t - r, 1, 1 - t + r);
  add_event(t - l + 1, -1, -l + t);
};
inline void dfs(segnode *a, int x, int n, int pos) {
  x = min(x, a->x);
  if (n == 1) {
    if (x == 1100000000) return;
    if (_tmp[pos] == _tmp[pos + 1]) return;
    add_seg(x, _tmp[pos], _tmp[pos + 1] - 1);
    return;
  };
  int mid = n >> 1;
  dfs(a->l, x, mid, pos);
  dfs(a->r, x, n - mid, pos + mid);
};
int main() {
  read(n);
  read(m);
  int i;
  for (i = 1; i <= m; i++) {
    int l, r, t;
    read(l);
    read(r);
    read(t);
    a[i] = (data){l, r - 1, t};
    _tmp[i] = l, _tmp[i + m] = r;
  };
  std::sort(a + 1, a + m + 1);
  std::sort(_tmp + 1, _tmp + m + m + 1);
  _tmp[m + m + 1] = _tmp[m + m + 1];
  segnode *root = build(2 * m);
  for (i = 1; i <= m; i++) {
    cover(root, std::lower_bound(_tmp + 1, _tmp + m + m + 1, a[i].l) - _tmp,
          std::lower_bound(_tmp + 1, _tmp + m + m + 1, a[i].r + 1) - _tmp - 1,
          a[i].t, m + m);
  };
  dfs(root, 1100000000, m + m, 1);
  std::sort(e + 1, e + ecnt + 1);
  int k = 0, b = 0;
  int now = 1;
  for (i = 1; i <= n; i++) {
    int x;
    read(x);
    while (now <= ecnt && e[now].t <= x) {
      k += e[now].dk;
      b += e[now].db;
      ++now;
    };
    int ans = 1LL * k * x + b;
    printf("%d\n", ans);
  };
}
