#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e16;
const int maxn = 200015;
int n, m, i, j, t, k, s, N, head[maxn];
struct Edge {
  int nxt, aim, co;
} edge[maxn];
inline void add_edge(int x, int y, int z) {
  edge[++N] = (Edge){head[x], y, z};
  head[x] = N;
}
long long seg[maxn << 2], f[maxn], qz[maxn], laz[maxn << 2], laz2[maxn << 2];
void build(int rt, int l, int r) {
  laz2[rt] = -INF;
  if (l == r) {
    seg[rt] = qz[l - 1];
    return;
  }
  int mid = (l + r) / 2;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
  seg[rt] = max(seg[rt << 1], seg[rt << 1 | 1]);
}
inline void pushdown(int rt, int l, int mid, int r) {
  if (laz[rt] > 0) {
    long long tmp = laz[rt];
    laz[rt] = 0;
    laz[rt << 1] += tmp;
    laz[rt << 1 | 1] += tmp;
    laz2[rt << 1] += tmp;
    laz2[rt << 1 | 1] += tmp;
    seg[rt << 1] += tmp;
    seg[rt << 1 | 1] += tmp;
  }
  if (laz2[rt] >= -1e14) {
    long long tmp = laz2[rt];
    laz2[rt] = -INF;
    laz2[rt << 1] = max(laz2[rt << 1], tmp);
    laz2[rt << 1 | 1] = max(laz2[rt << 1 | 1], tmp);
    seg[rt << 1] = max(seg[rt << 1], tmp + qz[mid - 1]);
    seg[rt << 1 | 1] = max(seg[rt << 1 | 1], tmp + qz[r - 1]);
  }
}
long long query(int rt, int l, int r, int L, int R) {
  if (l >= L && r <= R) return seg[rt];
  int mid = (l + r) / 2;
  pushdown(rt, l, mid, r);
  if (R <= mid) return query(rt << 1, l, mid, L, R);
  if (L > mid) return query(rt << 1 | 1, mid + 1, r, L, R);
  return max(query(rt << 1, l, mid, L, R),
             query(rt << 1 | 1, mid + 1, r, L, R));
}
void upd_p(int rt, int l, int r, int L, int R, long long x) {
  if (l >= L && r <= R) {
    seg[rt] = max(seg[rt], x + qz[r - 1]);
    laz2[rt] = max(laz2[rt], x);
    return;
  }
  int mid = (l + r) / 2;
  pushdown(rt, l, mid, r);
  if (L <= mid) upd_p(rt << 1, l, mid, L, R, x);
  if (R > mid) upd_p(rt << 1 | 1, mid + 1, r, L, R, x);
  seg[rt] = max(seg[rt << 1], seg[rt << 1 | 1]);
}
void upd(int rt, int l, int r, int L, int R, long long ad) {
  if (l >= L && r <= R) {
    seg[rt] += ad;
    laz[rt] += ad;
    laz2[rt] += ad;
    return;
  }
  int mid = (l + r) / 2;
  pushdown(rt, l, mid, r);
  if (L <= mid) upd(rt << 1, l, mid, L, R, ad);
  if (R > mid) upd(rt << 1 | 1, mid + 1, r, L, R, ad);
  seg[rt] = max(seg[rt << 1], seg[rt << 1 | 1]);
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &t);
    qz[i] = qz[i - 1] + t;
  }
  for (i = 1; i <= m; ++i) {
    scanf("%d%d%d", &t, &k, &s);
    add_edge(k, t, s);
  }
  build(1, 1, n);
  long long ans = 0;
  for (i = 1; i <= n; ++i) {
    for (j = head[i]; j; j = edge[j].nxt) {
      upd(1, 1, n, 1, edge[j].aim, edge[j].co);
    }
    f[i] = max(query(1, 1, n, 1, i) - qz[i], 0ll);
    ans = max(ans, f[i]);
    upd_p(1, 1, n, i + 1, n, f[i]);
  }
  printf("%lld\n", ans);
  return 0;
}
