#include <bits/stdc++.h>
using namespace std;
struct arr {
  int x, y;
};
arr make(int xx, int yy) {
  arr ret;
  ret.x = xx;
  ret.y = yy;
  return ret;
}
bool comp(arr a, arr b) { return a.x > b.x; }
long long f[400010];
int n, m, cost[400010], x, y, z;
vector<arr> a[400010];
struct node {
  long long mark, num;
};
struct SegmentTree {
  node c[1600000];
  void update(int now) {
    if (!c[now].mark) return;
    if (now < 800000) {
      c[now * 2].mark += c[now].mark;
      c[now * 2 + 1].mark += c[now].mark;
    }
    c[now].num += c[now].mark;
    c[now].mark = 0;
  }
  void add(int l, int r, int ll, int rr, int now, long long ad) {
    if (l == ll && r == rr) {
      c[now].mark += ad;
      return;
    }
    update(now);
    int t = (l + r) / 2;
    if (rr <= t)
      add(l, t, ll, rr, now * 2, ad);
    else if (ll > t)
      add(t + 1, r, ll, rr, now * 2 + 1, ad);
    else
      add(l, t, ll, t, now * 2, ad), add(t + 1, r, t + 1, rr, now * 2 + 1, ad);
    update(now * 2);
    update(now * 2 + 1);
    c[now].num = max(c[now * 2].num, c[now * 2 + 1].num);
  }
  long long ask(int l, int r, int ll, int rr, int now) {
    update(now);
    if (l == ll && r == rr) return c[now].num;
    int t = (l + r) / 2;
    if (rr <= t)
      return ask(l, t, ll, rr, now * 2);
    else if (ll > t)
      return ask(t + 1, r, ll, rr, now * 2 + 1);
    else
      return max(ask(l, t, ll, t, now * 2),
                 ask(t + 1, r, t + 1, rr, now * 2 + 1));
  }
} xds;
void read(int &k) {
  k = 0;
  char x = getchar();
  while (x < '0' || x > '9') x = getchar();
  while (x >= '0' && x <= '9') {
    k = k * 10 - 48 + x;
    x = getchar();
  }
}
int main() {
  read(n);
  read(m);
  for (int i = 1; i <= n; i++) read(cost[i]);
  for (int i = 1; i <= m; i++) {
    read(x);
    read(y);
    read(z);
    a[y].push_back(make(x, z));
  }
  for (int i = 1; i <= n; i++) sort(a[i].begin(), a[i].end(), comp);
  for (int i = 1; i <= n; i++) {
    int l = a[i].size();
    xds.add(1, n, 1, i, 1, -cost[i]);
    xds.add(1, n, i, i, 1, f[i - 1]);
    for (int j = 0; j < l; j++) xds.add(1, n, 1, a[i][j].x, 1, a[i][j].y);
    f[i] = max(f[i - 1], xds.ask(1, n, 1, i, 1));
  }
  cout << f[n] << endl;
  return 0;
}
