#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const unsigned gen_seed =
    std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);
const int INF = 2e9;
class streemin {
 public:
  std::vector<int> t;
  int s;
  void build(int n, int v, int tl, int tr) {
    if (v == 1) {
      t.resize(n * 4);
      s = n;
    }
    if (tl == tr)
      t[v] = INF;
    else {
      int tm = (tl + tr) / 2;
      build(n, v * 2, tl, tm);
      build(n, v * 2 + 1, tm + 1, tr);
      t[v] = INF;
    }
  }
  void update(int v, int tl, int tr, int l, int r, int val) {
    if (l > r) return;
    if (l == tl && tr == r)
      t[v] = min(t[v], val);
    else {
      int tm = (tl + tr) / 2;
      update(v * 2, tl, tm, l, min(r, tm), val);
      update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val);
    }
  }
  int get(int v, int tl, int tr, int pos) {
    if (tl == tr) return t[v];
    int tm = (tl + tr) / 2;
    if (pos <= tm)
      return min(t[v], get(v * 2, tl, tm, pos));
    else
      return min(t[v], get(v * 2 + 1, tm + 1, tr, pos));
  }
};
class stree {
 public:
  std::vector<long long> t;
  int s;
  void build(int n) {
    s = n;
    t = std::vector<long long>(4 * n, 0);
  }
  void update(int v, int tl, int tr, int l, int r, long long add) {
    if (l > r) return;
    if (l == tl && tr == r)
      t[v] += add;
    else {
      int tm = (tl + tr) / 2;
      update(v * 2, tl, tm, l, min(r, tm), add);
      update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, add);
    }
  }
  long long get(int v, int tl, int tr, int pos) {
    if (tl == tr) return t[v];
    int tm = (tl + tr) / 2;
    if (pos <= tm)
      return t[v] + get(v * 2, tl, tm, pos);
    else
      return t[v] + get(v * 2 + 1, tm + 1, tr, pos);
  }
};
int main() {
  int n;
  int m;
  scanf("%d", &m);
  scanf("%d", &n);
  std::vector<int> l(n), r(n), t(n);
  set<int> pos;
  pos.insert(0);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &l[i], &r[i], &t[i]);
    pos.insert(l[i]);
    pos.insert(r[i]);
  }
  std::vector<int> q(m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &q[i]);
    q[i] = -q[i];
  }
  reverse((q).begin(), (q).end());
  std::vector<int> px;
  for (auto x : pos) px.push_back(x);
  int k = px.size();
  streemin st;
  map<int, int> to;
  st.build(k, 1, 0, k - 1);
  for (int i = 0; i < k; i++) to[px[i]] = i;
  for (int i = 0; i < n; i++) {
    int tl = to[l[i]];
    int tr = to[r[i]];
    st.update(1, 0, k - 1, tl, tr - 1, t[i]);
  }
  stree stc, stx;
  stc.build(m);
  stx.build(m);
  for (int i = 0; i < k - 1; i++) {
    int tm = st.get(1, 0, k - 1, i);
    if (tm == INF) continue;
    int tl = px[i];
    int tr = px[i + 1];
    int ql = lower_bound((q).begin(), (q).end(), tl - tm) - q.begin();
    int qr = upper_bound((q).begin(), (q).end(), tr - tm) - q.begin();
    qr--;
    stc.update(1, 0, m - 1, 0, ql - 1, tr - tl);
    if (qr >= ql) {
      stx.update(1, 0, m - 1, ql, qr, -1);
      stc.update(1, 0, m - 1, ql, qr, tr - tm);
    }
  }
  for (int i = m - 1; i >= 0; i--) {
    long long c = stc.get(1, 0, m - 1, i);
    long long x = stx.get(1, 0, m - 1, i);
    printf("%lld\n", q[i] * x + c);
  }
}
