#include <bits/stdc++.h>
using namespace std;
pair<int, int> in[510000];
int l[510000], r[510000], t[510000], p[510000], tm[510000], q[510000];
int sum[510000], ans[510000];
int N, M, K, T;
template <class cup>
struct segtree {
  struct Node {
    int s, e, l, r;
    Node(int _s = 0, int _e = 0) {
      s = _s;
      e = _e;
    }
    cup val;
  };
  int ncnt;
  Node node[3 * 510000];
  segtree() { ncnt = 0; }
  void clear() { ncnt = 0; }
  void pushdown(int n) {
    node[node[n].l].val = min(node[node[n].l].val, node[n].val);
    node[node[n].r].val = min(
        node[node[n].r].val, node[n].val - p[node[node[n].r].s] + p[node[n].s]);
  }
  cup calc(int n, int s, int e) {
    s = max(node[n].s, s);
    e = min(node[n].e, e);
    if (s >= e) return 2000000000;
    if (node[n].s == s && node[n].e == e) return node[n].val;
    pushdown(n);
    return min(calc(node[n].l, s, e), calc(node[n].r, s, e));
  }
  void update(int n, int s, int e, int o, cup v) {
    s = max(node[n].s, s);
    e = min(node[n].e, e);
    if (s >= e) return;
    if (node[n].s == s && node[n].e == e) {
      node[n].val = min(node[n].val, v - p[s] + p[o]);
      return;
    }
    pushdown(n);
    update(node[n].l, s, e, o, v);
    update(node[n].r, s, e, o, v);
  }
  int build(int s, int e) {
    int n = ncnt++;
    node[n].s = s;
    node[n].e = e;
    if (s + 1 == e) {
      node[n].val = 2000000000;
      return n;
    }
    int m = (s + e) / 2;
    int l = build(s, m);
    int r = build(m, e);
    node[n].l = l;
    node[n].r = r;
    node[n].val = 2000000000;
    return n;
  }
};
segtree<int> tree;
void update(int *bit, int u, int v) {
  while (u <= T) {
    bit[u] += v;
    u += u & -u;
  }
}
int calc(int *bit, int u) {
  int ret = 0;
  while (u) {
    ret += bit[u];
    u -= u & -u;
  }
  return ret;
}
int bit[510000], cnt[510000];
int main() {
  int i, k, id, len;
  scanf("%d%d", &N, &M);
  for (i = 0; i < M; i++) {
    scanf("%d%d%d", l + i, r + i, t + i);
    p[i] = l[i];
    p[M + i] = r[i];
    t[i] -= l[i];
  }
  sort(p, p + 2 * M);
  K = unique(p, p + 2 * M) - p;
  tree.clear();
  tree.build(0, K - 1);
  for (i = 0; i < M; i++) {
    l[i] = lower_bound(p, p + K, l[i]) - p;
    r[i] = lower_bound(p, p + K, r[i]) - p;
    tree.update(0, l[i], r[i], l[i], t[i]);
  }
  T = 0;
  for (i = 0; i < K - 1; i++) {
    t[i] = tree.calc(0, i, i + 1);
    in[i] = pair<int, int>(t[i], p[i + 1] - p[i]);
    tm[T++] = t[i] - (p[i + 1] - p[i]);
  }
  sort(in, in + K - 1);
  for (i = 0; i < N; i++) {
    scanf("%d", q + i);
    tm[T++] = q[i];
  }
  sort(tm, tm + T);
  T = unique(tm, tm + T) - tm;
  for (i = 0; i < K - 1; i++) {
    if (i)
      sum[i] = sum[i - 1] + in[i].second;
    else
      sum[i] = in[i].second;
  }
  for (i = 0; i < N; i++) {
    k = upper_bound(in, in + K - 1, pair<int, int>(q[i], 2000000000)) - in;
    if (k)
      ans[i] = sum[k - 1];
    else
      ans[i] = 0;
  }
  memset(bit, 0, sizeof(bit));
  memset(cnt, 0, sizeof(cnt));
  for (i = K - 2, k = N - 1; k >= 0; k--) {
    while (i >= 0 && in[i].first > q[k]) {
      len = in[i].first - in[i].second;
      id = lower_bound(tm, tm + T, len) - tm;
      update(cnt, id + 1, 1);
      update(bit, id + 1, -len);
      i--;
    }
    id = lower_bound(tm, tm + T, q[k]) - tm;
    ans[k] += calc(bit, id + 1) + q[k] * calc(cnt, id + 1);
  }
  for (i = 0; i < N; i++) printf("%d\n", ans[i]);
  return 0;
}
