#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
using namespace std;
namespace _c {
const double pi = acos(-1.0);
namespace min {
const int i8 = -128;
const int i16 = -32768;
const int i = -2147483647 - 1;
const long long l = -9223372036854775807LL - 1;
}  // namespace min
namespace max {
const int i8 = 127;
const int i16 = 32767;
const int i = 2147483647;
const long long l = 9223372036854775807LL;
}  // namespace max
}  // namespace _c
namespace _f {
template <typename T>
inline const T gcd(T m, T n) {
  while (n != 0) {
    T t = m % n;
    m = n;
    n = t;
  }
  return m;
}
template <typename T>
inline const T max(const T &a, const T &b) {
  return a > b ? a : b;
}
template <typename T>
inline const T min(const T &a, const T &b) {
  return a < b ? a : b;
}
template <typename T>
inline const T abs(const T &a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline T pow(T a, T b) {
  T res = 1;
  while (b > 0) {
    if (b & 1) {
      res = res * a;
    }
    a = a * a;
    b >>= 1;
  }
  return res;
}
template <typename T>
inline T pow(T a, T b, const T &m) {
  a %= m;
  T res = 1;
  while (b > 0) {
    if (b & 1) {
      res = res * a % m;
    }
    a = a * a % m;
    b >>= 1;
  }
  return res % m;
}
}  // namespace _f
namespace io {
template <typename T>
inline void read(T &t) {
  register T res = 0, neg = 1;
  char g = getchar();
  for (; !isdigit(g); g = getchar()) {
    if (g == '-') {
      neg = -1;
    }
  }
  for (; isdigit(g); g = getchar()) {
    res = res * 10 + g - '0';
  }
  t = res * neg;
}
inline int in() {
  register int T;
  read(T);
  return T;
}
inline long long in_ll() {
  register long long T;
  read(T);
  return T;
}
}  // namespace io
struct node {
  int x, y, t;
} b[430000], a[430000];
int p[430000], x, y, t, n, m, i, j, tot, ftot, fa[430000], co[430000], l, ans,
    K;
bool cmp(const node &a, const node &b) { return a.t < b.t; }
int get(int x) { return fa[x] == x ? x : (fa[x] = get(fa[x])); }
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; ++i) {
    scanf("%d%d%d", &x, &y, &t);
    p[++tot] = x;
    p[++tot] = y;
    a[i].x = x;
    a[i].y = y;
    a[i].t = t;
  }
  sort(p + 1, p + tot + 1);
  sort(a + 1, a + m + 1, cmp);
  for (i = 1; i <= tot + 1; ++i) fa[i] = i, co[i] = -1;
  for (i = 1; i <= m; ++i) {
    x = lower_bound(p + 1, p + tot + 1, a[i].x) - p;
    y = lower_bound(p + 1, p + tot + 1, a[i].y) - p - 1;
    for (j = get(x); j <= y; j = get(j)) {
      co[j] = a[i].t;
      fa[j] = j + 1;
    }
  }
  for (i = 1; i < tot; ++i)
    if (co[i] != -1) {
      b[++ftot].t = co[i] - p[i + 1];
      b[ftot].x = 1;
      b[++ftot].t = co[i] - p[i];
      b[ftot].x = -1;
      b[ftot].y = -(p[i + 1] - p[i]);
    }
  sort(b + 1, b + ftot + 1, cmp);
  l = 1;
  for (i = 1; i <= n; ++i) {
    scanf("%d", &x);
    while (l <= ftot && x >= b[l].t) {
      ans += K * (b[l].t - b[l - 1].t);
      K += b[l].x;
      l++;
    }
    printf("%d\n", ans + K * (x - b[l - 1].t));
  }
}
