#include <bits/stdc++.h>
using namespace std;
const int maxn = int(2e5 + 10);
struct node {
  int l, r, w;
  friend bool operator<(const node& a, const node& b) { return a.r < b.r; }
  node(int l, int r, int w) : l(l), r(r), w(w) {}
  node() {}
} race[maxn];
long long tree[maxn << 2];
long long lazy[maxn << 2];
long long dp[maxn];
int cost[maxn];
void pushdown(int root, int l, int r) {
  if (lazy[root]) {
    tree[root << 1] += lazy[root];
    tree[root << 1 | 1] += lazy[root];
    lazy[root << 1] += lazy[root];
    lazy[root << 1 | 1] += lazy[root];
    lazy[root] = 0;
  }
}
long long query(int root, int l, int r, int lt, int rt) {
  if (lt == l && rt == r) return tree[root];
  pushdown(root, l, r);
  int mid = (l + r) >> 1;
  if (lt > mid)
    return query(root << 1 | 1, mid + 1, r, lt, rt);
  else if (rt <= mid)
    return query(root << 1, l, mid, lt, rt);
  else
    return max(query(root << 1, l, mid, lt, mid),
               query(root << 1 | 1, mid + 1, r, mid + 1, rt));
}
void update(int root, int l, int r, int lt, int rt, long long val) {
  if (lt == l && rt == r) {
    tree[root] += val;
    lazy[root] += val;
    return;
  }
  pushdown(root, l, r);
  int mid = (l + r) >> 1;
  if (lt > mid)
    update(root << 1 | 1, mid + 1, r, lt, rt, val);
  else if (rt <= mid)
    update(root << 1, l, mid, lt, rt, val);
  else {
    update(root << 1, l, mid, lt, mid, val);
    update(root << 1 | 1, mid + 1, r, mid + 1, rt, val);
  }
  tree[root] = max(tree[root << 1], tree[root << 1 | 1]);
}
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    memset(dp, 0, sizeof dp);
    memset(tree, 0, sizeof tree);
    memset(lazy, 0, sizeof lazy);
    for (int i = 1; i <= n; ++i) scanf("%d", cost + i);
    for (int i = 0; i < m; ++i)
      scanf("%d%d%d", &race[i].l, &race[i].r, &race[i].w);
    sort(race, race + m);
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
      dp[i] = dp[i - 1];
      update(1, 0, n, 0, i - 1, -cost[i]);
      int p = upper_bound(race, race + m, node(0, i, 0)) - race - 1;
      while (race[p].r == i) {
        update(1, 0, n, 0, race[p].l - 1, race[p].w);
        --p;
      }
      dp[i] = max(dp[i], query(1, 0, n, 0, i - 1));
      update(1, 0, n, i, i, dp[i]);
      ans = max(ans, dp[i]);
    }
    printf("%I64d\n", ans);
  }
}
