#include <bits/stdc++.h>
int l[200005 * 4], r[200005 * 4], n, m, cost[200005], rew[200005], be[200005],
    ed[200005];
long long val[200005 * 4], f[200005], tag[200005 * 4];
std::vector<int> ve[200005];
void build_up(int x, int ll, int rr) {
  l[x] = ll;
  r[x] = rr;
  if (ll == rr) {
    return;
  }
  int mid = ll + rr >> 1;
  build_up(x << 1, ll, mid);
  build_up(x << 1 | 1, mid + 1, rr);
}
void push_down(int x) {
  if (tag[x]) {
    val[x << 1] += tag[x];
    val[x << 1 | 1] += tag[x];
    tag[x << 1] += tag[x];
    tag[x << 1 | 1] += tag[x];
    tag[x] = 0;
  }
}
void change(int x, int ll, int rr, long long d) {
  if (ll <= l[x] && r[x] <= rr) {
    val[x] += d;
    tag[x] += d;
    return;
  }
  push_down(x);
  int mid = l[x] + r[x] >> 1;
  if (ll <= mid) change(x << 1, ll, rr, d);
  if (rr > mid) change(x << 1 | 1, ll, rr, d);
  val[x] = std::max(val[x << 1], val[x << 1 | 1]);
}
long long query(int x, int ll, int rr) {
  if (ll <= l[x] && r[x] <= rr) {
    return val[x];
  }
  push_down(x);
  int mid = l[x] + r[x] >> 1;
  long long ans = 0;
  if (ll <= mid) ans = std::max(ans, query(x << 1, ll, rr));
  if (rr > mid) ans = std::max(ans, query(x << 1 | 1, ll, rr));
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &cost[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &be[i], &ed[i], &rew[i]);
    ve[ed[i]].push_back(i);
  }
  build_up(1, 0, n);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < ve[i].size(); j++) {
      int p = ve[i][j];
      change(1, 0, be[p] - 1, rew[p]);
    }
    change(1, 0, i - 1, -cost[i]);
    f[i] = std::max(query(1, 0, i - 1), f[i - 1]);
    change(1, i, i, f[i]);
  }
  printf("%lld\n", f[n]);
  return 0;
}
