#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
const int mod = (int)1e9 + 7;
const int logN = 17;
const int inf = 1e9;
const int N = 2e5 + 5;
int n, m, x, y, t;
map<int, int> dp1, dp2, hh, p;
vector<int> h;
vector<pair<int, int> > add, del;
multiset<int> S;
void ad(int x, int y, int t) {
  y = t - (y - x);
  x = t;
  swap(x, y);
  dp1[x]++;
  dp1[y + 1]--;
  dp2[x] -= x - 1;
  dp2[y + 1] += x - 1;
  dp2[y + 1] += (y - x + 1);
  hh[x] = hh[y + 1] = 1;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &x, &y, &t);
    int s = t - x;
    --y;
    h.push_back(x);
    h.push_back(y + 1);
    add.push_back(make_pair(x, s));
    del.push_back(make_pair(y + 1, t - y - 1));
  }
  sort(h.begin(), h.end());
  h.resize(unique(h.begin(), h.end()) - h.begin());
  sort(add.begin(), add.end());
  sort(del.begin(), del.end());
  int last = 1, c = 0;
  int l1 = 0, l2 = 0;
  for (__typeof(h.begin()) it = h.begin(); it != h.end(); it++) {
    int x = *it;
    if (S.size()) ad(last, x - 1, (*S.begin()) + c);
    c -= (x - last);
    while (l1 < add.size() && add[l1].first < x) l1++;
    while (l2 < del.size() && del[l2].first < x) l2++;
    while (l1 < add.size() && add[l1].first == x)
      S.insert(add[l1++].second - c);
    while (l2 < del.size() && del[l2].first == x)
      S.erase(S.find(del[l2++].second - c));
    last = x;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    hh[x] = 1;
    p[x] = 1;
  }
  last = 0;
  for (__typeof(hh.begin()) it = hh.begin(); it != hh.end(); it++) {
    int x = it->first;
    if (it != hh.begin()) {
      dp1[x] += dp1[last];
      dp2[x] += dp2[last];
    }
    last = x;
    if (p.count(it->first)) {
      printf("%d\n", dp1[x] * x + dp2[x]);
    }
  }
  return 0;
}
