#include <bits/stdc++.h>
using namespace std;
int n, m, q[200010], c[200010], d[200010];
struct epoch {
  int l, r, t, ed, lx, rx;
} b[100010];
struct tnode {
  long long tag, _tag, cov;
  int l, r;
} tr[800010];
set<pair<int, int> > s;
std::set<pair<int, int> >::iterator bin[100010];
int find(int ave) {
  int l = 1, r = d[0];
  while (l <= r) {
    int mid = (l + r) / 2;
    if (d[mid] == ave) return mid;
    if (ave < d[mid])
      r = mid - 1;
    else
      l = mid + 1;
  }
  return 0;
}
void pre() {
  c[0] = d[0] = 0;
  for (int i = 1; i <= n; ++i) c[++c[0]] = q[i];
  sort(c + 1, c + c[0] + 1);
  for (int i = 1, j; i <= c[0]; i = j) {
    d[++d[0]] = c[i];
    for (j = i + 1; j <= c[0] && c[i] == c[j]; ++j)
      ;
  }
  for (int i = 1; i <= n; ++i) q[i] = find(q[i]);
}
void build(int p, int l, int r) {
  if (l == r) {
    tr[p].tag = tr[p]._tag = tr[p].cov = 0;
    return;
  }
  int mid = (l + r) / 2;
  tr[p].tag = tr[p]._tag = tr[p].cov = 0;
  build(p * 2, l, mid), build(p * 2 + 1, mid + 1, r);
}
int find_bg(int ave) {
  int l = 1, r = d[0], ans = d[0] + 1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (d[mid] >= ave)
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  return ans;
}
int find_sm(int ave) {
  int l = 1, r = d[0], ans = 0;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (d[mid] <= ave)
      ans = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  return ans;
}
void pushdown(int p, int lx, int rx) {
  int l = p * 2, r = p * 2 + 1;
  if (tr[p].tag) {
    tr[l].tag += tr[p].tag, tr[r].tag += tr[p].tag;
    tr[l].cov += tr[p].tag, tr[r].cov += tr[p].tag;
    tr[p].tag = 0;
  }
  if (tr[p]._tag) {
    tr[l].cov += tr[p]._tag * d[lx], tr[r].cov += tr[p]._tag * d[rx];
    tr[l]._tag += tr[p]._tag, tr[r]._tag += tr[p]._tag;
    tr[p]._tag = 0;
  }
}
void modify(int p, int l, int r, int lx, int rx, int ave) {
  if (l == lx && r == rx) {
    tr[p].tag += ave;
    tr[p].cov += ave;
    return;
  }
  int mid = (l + r) / 2;
  pushdown(p, l, r);
  if (rx <= mid)
    modify(p * 2, l, mid, lx, rx, ave);
  else if (lx > mid)
    modify(p * 2 + 1, mid + 1, r, lx, rx, ave);
  else
    modify(p * 2, l, mid, lx, mid, ave),
        modify(p * 2 + 1, mid + 1, r, mid + 1, rx, ave);
}
void _modify(int p, int l, int r, int lx, int rx, int ave) {
  if (l == lx && r == rx) {
    tr[p]._tag += ave;
    tr[p].cov += (long long)ave * d[l];
    return;
  }
  int mid = (l + r) / 2;
  pushdown(p, l, r);
  if (rx <= mid)
    _modify(p * 2, l, mid, lx, rx, ave);
  else if (lx > mid)
    _modify(p * 2 + 1, mid + 1, r, lx, rx, ave);
  else
    _modify(p * 2, l, mid, lx, mid, ave),
        _modify(p * 2 + 1, mid + 1, r, mid + 1, rx, ave);
}
long long query(int p, int l, int r, int pos) {
  if (l == pos && r == pos) return tr[p].cov;
  int mid = (l + r) / 2;
  pushdown(p, l, r);
  if (pos <= mid) return query(p * 2, l, mid, pos);
  return query(p * 2 + 1, mid + 1, r, pos);
}
void _pushdown(int p, int lx, int mid, int rx) {
  int l = p * 2, r = p * 2 + 1;
  if (tr[p].tag) {
    tr[l].l = tr[l].r = mid - lx + 1, tr[r].l = tr[r].r = rx - mid;
    tr[l].tag = tr[r].tag = 1;
    tr[p].tag = 0;
  }
}
void update(int p, int lx, int mid, int rx) {
  int l = p * 2, r = p * 2 + 1;
  if (tr[l].l < mid - lx + 1)
    tr[p].l = tr[l].l;
  else
    tr[p].l = tr[l].l + tr[r].l;
  if (tr[r].r < rx - mid)
    tr[p].r = tr[r].r;
  else
    tr[p].r = tr[r].r + tr[l].r;
}
void sgt_build(int p, int l, int r) {
  if (l == r) {
    tr[p].l = tr[p].r = 0;
    return;
  }
  tr[p].l = tr[p].r = 0;
  int mid = (l + r) / 2;
  sgt_build(p * 2, l, mid), sgt_build(p * 2 + 1, mid + 1, r);
}
void add(int p, int l, int r, int lx, int rx) {
  if (l == lx && r == rx) {
    tr[p].tag = 1;
    tr[p].l = tr[p].r = r - l + 1;
    return;
  }
  int mid = (l + r) / 2;
  _pushdown(p, l, mid, r);
  if (rx <= mid)
    add(p * 2, l, mid, lx, rx);
  else if (lx > mid)
    add(p * 2 + 1, mid + 1, r, lx, rx);
  else
    add(p * 2, l, mid, lx, mid), add(p * 2 + 1, mid + 1, r, mid + 1, rx);
  update(p, l, mid, r);
}
int query_l(int p, int l, int r, int lx, int rx) {
  if (l == lx && r == rx) return tr[p].l;
  int mid = (l + r) / 2;
  _pushdown(p, l, mid, r);
  if (rx <= mid) return query_l(p * 2, l, mid, lx, rx);
  if (lx > mid) return query_l(p * 2 + 1, mid + 1, r, lx, rx);
  int tmp = query_l(p * 2, l, mid, lx, mid);
  if (tmp < mid - lx + 1)
    return tmp;
  else
    return tmp + query_l(p * 2 + 1, mid + 1, r, mid + 1, rx);
}
int query_r(int p, int l, int r, int lx, int rx) {
  if (l == lx && r == rx) return tr[p].r;
  int mid = (l + r) / 2;
  _pushdown(p, l, mid, r);
  if (rx <= mid) return query_r(p * 2, l, mid, lx, rx);
  if (lx > mid) return query_r(p * 2 + 1, mid + 1, r, lx, rx);
  int tmp = query_r(p * 2 + 1, mid + 1, r, mid + 1, rx);
  if (tmp < rx - mid)
    return tmp;
  else
    return tmp + query_r(p * 2, l, mid, lx, mid);
}
bool _cmp(epoch a, epoch b) { return a.t < b.t; }
void _pre() {
  c[0] = d[0] = 0;
  for (int i = 1; i <= m; ++i) c[++c[0]] = b[i].l, c[++c[0]] = b[i].r;
  sort(c + 1, c + c[0] + 1);
  for (int i = 1, j; i <= c[0]; i = j) {
    d[++d[0]] = c[i];
    for (j = i + 1; j <= c[0] && c[i] == c[j]; ++j)
      ;
  }
  for (int i = 1; i <= m; ++i)
    b[i].lx = find(b[i].l), b[i].rx = find(b[i].r) - 1;
}
void solve() {
  _pre();
  sgt_build(1, 1, d[0]);
  sort(b + 1, b + m + 1, _cmp);
  for (int i = 1; i <= m; ++i) b[i].ed = 1000000007;
  for (int i = 1; i <= m; ++i) {
    int l2 = query_l(1, 1, d[0], b[i].lx, b[i].rx),
        r2 = query_r(1, 1, d[0], b[i].lx, b[i].rx);
    b[i].lx += l2, b[i].rx -= r2;
    if (b[i].lx > b[i].rx) {
      b[i].ed = -1000000007;
      continue;
    }
    b[i].l = d[b[i].lx], b[i].r = d[b[i].rx + 1];
    int tot = 0;
    for (std::set<pair<int, int> >::iterator p =
             s.lower_bound(make_pair(b[i].lx, 0));
         p != s.end(); ++p) {
      int now = (*p).second;
      if (b[now].rx <= b[i].rx)
        bin[++tot] = p;
      else
        break;
    }
    for (int j = 1; j <= tot; ++j) {
      int now = (*bin[j]).second;
      b[now].ed = b[i].t;
      s.erase(bin[j]);
    }
    s.insert(make_pair(b[i].lx, i));
    add(1, 1, d[0], b[i].lx, b[i].rx);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) scanf("%d%d%d", &b[i].l, &b[i].r, &b[i].t);
  solve();
  for (int i = 1; i <= n; ++i) scanf("%d", &q[i]);
  pre(), build(1, 1, d[0]);
  for (int i = 1; i <= m; ++i) {
    if (b[i].ed == -1000000007) continue;
    if (b[i].ed == 1000000007) {
      int x = find_bg(b[i].t - b[i].r), y = find_sm(b[i].t - b[i].l);
      if (y + 1 <= d[0]) modify(1, 1, d[0], y + 1, d[0], b[i].r - b[i].l);
      if (x <= y)
        _modify(1, 1, d[0], x, y, 1), modify(1, 1, d[0], x, y, b[i].r - b[i].t);
    } else {
      if (b[i].t - b[i].l < b[i].ed - b[i].r) {
        int x, y;
        x = find_bg(b[i].t - b[i].r), y = find_sm(b[i].t - b[i].l);
        if (x <= y)
          _modify(1, 1, d[0], x, y, 1),
              modify(1, 1, d[0], x, y, b[i].r - b[i].t);
        x = y + 1, y = find_sm(b[i].ed - b[i].r);
        if (x <= y) modify(1, 1, d[0], x, y, b[i].r - b[i].l);
        x = y + 1, y = find_sm(b[i].ed - b[i].l);
        if (x <= y)
          _modify(1, 1, d[0], x, y, -1),
              modify(1, 1, d[0], x, y, b[i].ed - b[i].l);
      } else {
        int x, y;
        x = find_bg(b[i].t - b[i].r), y = find_sm(b[i].ed - b[i].r);
        if (x <= y)
          _modify(1, 1, d[0], x, y, 1),
              modify(1, 1, d[0], x, y, b[i].r - b[i].t);
        x = y + 1, y = find_sm(b[i].t - b[i].l);
        if (x <= y) modify(1, 1, d[0], x, y, b[i].ed - b[i].t);
        x = y + 1, y = find_sm(b[i].ed - b[i].l);
        if (x <= y)
          _modify(1, 1, d[0], x, y, -1),
              modify(1, 1, d[0], x, y, b[i].ed - b[i].l);
      }
    }
  }
  for (int i = 1; i <= n; ++i) printf("%lld\n", query(1, 1, d[0], q[i]));
  return 0;
}
