#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
int n, m;
int cost[maxn];
long long f[maxn], sum[maxn];
struct node {
  int l, r, p;
  bool operator<(const node& a) const {
    if (r != a.r)
      return r < a.r;
    else
      return l < a.l;
  }
} race[maxn];
struct Segtree {
  int l, r;
  long long maxx, mark;
} tree[maxn << 2];
void Push_Down(int rt) {
  tree[rt << 1].mark += tree[rt].mark;
  tree[rt << 1].maxx += tree[rt].mark;
  tree[rt << 1 | 1].mark += tree[rt].mark;
  tree[rt << 1 | 1].maxx += tree[rt].mark;
  tree[rt].mark = 0;
}
void Build(int rt, int l, int r) {
  tree[rt].l = l, tree[rt].r = r;
  tree[rt].maxx = tree[rt].mark = 0;
  int mid = ((tree[rt].l + tree[rt].r) >> 1);
  if (l != r) {
    Build(rt << 1, l, mid);
    Build(rt << 1 | 1, mid + 1, r);
  }
}
void Change(int rt, int l, int r, long long val) {
  if (tree[rt].l == l && tree[rt].r == r) {
    tree[rt].mark += val;
    tree[rt].maxx += val;
    return;
  }
  Push_Down(rt);
  int mid = ((tree[rt].l + tree[rt].r) >> 1);
  if (r <= mid)
    Change(rt << 1, l, r, val);
  else if (l > mid)
    Change(rt << 1 | 1, l, r, val);
  else {
    Change(rt << 1, l, mid, val);
    Change(rt << 1 | 1, mid + 1, r, val);
  }
  tree[rt].maxx = max(tree[rt << 1].maxx, tree[rt << 1 | 1].maxx);
}
long long Query(int rt, int l, int r) {
  if (tree[rt].l == l && tree[rt].r == r) return tree[rt].maxx;
  Push_Down(rt);
  int mid = ((tree[rt].l + tree[rt].r) >> 1);
  if (r <= mid)
    return Query(rt << 1, l, r);
  else if (l > mid)
    return Query(rt << 1 | 1, l, r);
  else
    return max(Query(rt << 1, l, mid), Query(rt << 1 | 1, mid + 1, r));
}
void solve() {
  Build(1, 0, n + 1);
  f[0] = 0;
  Change(1, 0, 0, f[0]);
  int last = 1;
  for (int i = 1; i <= n + 1; ++i) {
    while (last <= m && race[last].r < i) {
      Change(1, 0, race[last].l - 1, race[last].p);
      ++last;
    }
    f[i] = max(f[i - 1], Query(1, 0, i - 1));
    Change(1, i, i, f[i]);
    Change(1, 0, i - 1, -cost[i]);
  }
  cout << f[n + 1] << endl;
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    memset(f, 0, sizeof(f));
    for (int i = 1; i <= n; ++i) scanf("%d", cost + i);
    for (int i = 1; i <= m; ++i)
      scanf("%d%d%d", &race[i].l, &race[i].r, &race[i].p);
    sort(race + 1, race + m + 1);
    solve();
  }
  return 0;
}
