#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 100010;
struct node1 {
  int l, r, t;
  const bool operator<(const node1 x) const {
    if (l == x.l) return r < x.r;
    return l > x.l;
  }
};
priority_queue<node1> qt1;
int n, m;
int a[N], b[N], c[N], sum[N];
int binsearch(int l, int r, int k, int t) {
  while (l <= r) {
    int mid = (l + r) >> 1;
    if ((t - a[mid]) < k)
      r = mid - 1;
    else
      l = mid + 1;
  }
  if (l > r) swap(l, r);
  if (l > 0 && (t - a[l]) < k) {
    return l;
  }
  return r;
}
void add(node1 x1) {
  int l = binsearch(1, n + 1, x1.r, x1.t);
  int r = binsearch(1, n + 1, x1.l, x1.t);
  if (l >= r) {
    c[r] += (x1.r - x1.l + 1);
  } else {
    ++b[l];
    c[l] += (x1.r - (x1.t - a[l]));
    --b[r];
    c[r] -= ((x1.r - (x1.t - a[r]) - (x1.r - x1.l + 1)));
  }
}
int main() {
  while (scanf("%d %d", &n, &m) != EOF) {
    while (!qt1.empty()) qt1.pop();
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    memset(c, 0, sizeof(c));
    memset(sum, 0, sizeof(sum));
    node1 x1, y1, z1;
    while (m--) {
      scanf("%d %d %d", &x1.l, &x1.r, &x1.t);
      ++x1.l;
      qt1.push(x1);
    }
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    a[n + 1] = ceil(1e9);
    x1 = qt1.top();
    qt1.pop();
    while (!qt1.empty()) {
      y1 = qt1.top();
      qt1.pop();
      if (y1.l > x1.r) {
        add(x1);
        x1 = y1;
        continue;
      }
      if (y1.t == x1.t) {
        x1.r = max(x1.r, y1.r);
        continue;
      }
      if (y1.t < x1.t) {
        if (x1.l == y1.l) {
          if (y1.r >= x1.r)
            x1 = y1;
          else {
            z1.l = y1.r + 1;
            z1.r = x1.r;
            z1.t = x1.t;
            qt1.push(z1);
            x1 = y1;
          }
          continue;
        }
        if (y1.r >= x1.r) {
          x1.r = y1.l - 1;
          add(x1);
          x1 = y1;
        } else {
          z1.l = y1.r + 1;
          z1.r = x1.r;
          z1.t = x1.t;
          qt1.push(z1);
          x1.r = y1.l - 1;
          add(x1);
          x1 = y1;
        }
        continue;
      }
      if (y1.t > x1.t) {
        if (y1.r <= x1.r)
          continue;
        else {
          y1.l = x1.r + 1;
          qt1.push(y1);
        }
        continue;
      }
    }
    add(x1);
    for (int i = 1; i <= n; ++i) {
      sum[i] = sum[i - 1] + (b[i - 1] * (a[i] - a[i - 1])) + c[i];
      printf("%d\n", sum[i]);
      b[i] += b[i - 1];
    }
  }
  return 0;
}
