#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
int n, m, l[N], r[N], t[N];
int ans[N], tot;
struct Point {
  int x, y, type;
} pts[N * 5], tmp[N << 1];
void prepare() {
  tot = 0;
  sort(tmp, tmp + m + m, [=](const Point &lhs, const Point &rhs) {
    return lhs.x < rhs.x || (lhs.x == rhs.x) && lhs.type < rhs.type ||
           (lhs.x == rhs.x) && (lhs.type == rhs.type) &&
               (t[lhs.y] < t[rhs.y] && lhs.type == 0 ||
                lhs.type == 1 && t[lhs.y] > t[rhs.y]);
  });
  map<int, int> mp;
  mp.clear();
  int h = INF;
  mp[h]++;
  for (int i = 0; i < (m << 1); ++i) {
    int curh = t[tmp[i].y];
    if (tmp[i].type == 0) {
      ++mp[curh];
      if (curh < h) {
        h = curh;
        pts[tot++] = Point{tmp[i].x, h, -3};
      }
    } else {
      --mp[curh];
      if (mp[curh] == 0 && curh != h) {
        mp.erase(curh);
      } else if (mp[curh] == 0 && curh == h) {
        mp.erase(curh);
        map<int, int>::iterator p = mp.upper_bound(h);
        h = p->first;
        if (h < INF) pts[tot++] = Point{tmp[i].x, h, -3};
      }
    }
  }
  sort(tmp, tmp + m + m, [=](const Point &lhs, const Point &rhs) {
    return lhs.x > rhs.x || (lhs.x == rhs.x) && lhs.type > rhs.type ||
           (lhs.x == rhs.x) && (lhs.type == rhs.type) &&
               (t[lhs.y] < t[rhs.y] && lhs.type == 1 ||
                t[lhs.y] > t[rhs.y] && lhs.type == 0);
  });
  h = INF;
  for (int i = 0; i < (m << 1); ++i) {
    int curh = t[tmp[i].y];
    if (tmp[i].type == 1) {
      ++mp[curh];
      if (curh < h) {
        h = curh;
        pts[tot++] = Point{tmp[i].x, h, -1};
      }
    } else {
      --mp[curh];
      if (mp[curh] == 0 && curh != h) {
        mp.erase(curh);
      } else if (mp[curh] == 0 && curh == h) {
        mp.erase(curh);
        map<int, int>::iterator p = mp.upper_bound(h);
        h = p->first;
        if (h < INF) pts[tot++] = Point{tmp[i].x, h, -1};
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d", l + i, r + i, t + i);
    tmp[i << 1] = Point{l[i], i, 0};
    tmp[i << 1 | 1] = Point{r[i], i, 1};
  }
  prepare();
  for (int i = 0; i < n; ++i) {
    int q;
    scanf("%d", &q);
    pts[tot++] = Point{0, q, i};
  }
  for (int i = 0; i < tot; ++i) pts[i].y -= pts[i].x;
  sort(pts, pts + tot,
       [=](const Point &lhs, const Point &rhs) { return lhs.y < rhs.y; });
  int len = 0, lasty = pts[0].y, delta = 0;
  for (int i = 0; i < tot; ++i) {
    int deltay = pts[i].y - lasty;
    len += delta * deltay;
    lasty = pts[i].y;
    if (pts[i].type >= 0) {
      ans[pts[i].type] = len;
    } else {
      delta += pts[i].type + 2;
    }
  }
  for (int i = 0; i < n; ++i) printf("%d\n", ans[i]);
  return 0;
}
