#include <bits/stdc++.h>
using namespace std;
template <typename T, typename S>
inline bool REMIN(T& a, const S& b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T, typename S>
inline bool REMAX(T& a, const S& b) {
  return a < b ? a = b, 1 : 0;
}
int bit(long long x, int pos) { return (x >> pos) & 1; }
long long power(long long base, long long exp, long long c = 1e9 + 7) {
  if (!exp) return 1;
  long long r = power(base, exp >> 1, c);
  r = (r * r) % c;
  if (exp & 1) r = (r * base) % c;
  return r;
}
void nope(int dec = 0) {
  if (!dec)
    cout << "NO";
  else
    cout << dec;
  exit(0);
}
const long double PI = 2 * acos(0);
const long long INF = 1e9;
const int NMAX = 3e5 + 5;
const long long MOD = 1000000007;
long long T, N, M;
int a, b, c;
string s1, s2;
struct node {
  long long lazy = 0;
  long long val = -9999999999999999ll;
};
node seg[int(8e5)], empt;
node combine(node a, node b) {
  node c;
  c.lazy = 0;
  c.val = max(b.val, a.val);
  return c;
}
void build(int idx, int begin, int end) {
  if (begin == end)
    seg[idx].val = 0;
  else {
    int mid = (begin + end) >> 1;
    build(idx << 1, begin, mid);
    build((idx << 1) + 1, mid + 1, end);
    seg[idx] = combine(seg[idx << 1], seg[(idx << 1) + 1]);
  }
}
void apply(int idx, long long v) { seg[idx].lazy += v; }
void down(int idx, int l, int r) {
  if (seg[idx].lazy) {
    if (l != r) {
      apply(idx << 1, seg[idx].lazy);
      apply((idx << 1) | 1, seg[idx].lazy);
    }
    node c;
    c.lazy = 0;
    c.val = seg[idx].val + seg[idx].lazy;
    seg[idx] = c;
  }
}
void update(int idx, int begin, int end, int l, int r, long long v) {
  down(idx, begin, end);
  if (r < begin || end < l) return;
  if (l <= begin && end <= r) {
    apply(idx, v);
    down(idx, begin, end);
  } else {
    int mid = (begin + end) >> 1;
    update(idx << 1, begin, mid, l, r, v);
    update((idx << 1) | 1, mid + 1, end, l, r, v);
    seg[idx] = combine(seg[idx << 1], seg[(idx << 1) | 1]);
  }
}
node query(int idx, int begin, int end, int l, int r) {
  if (r < begin || end < l) return empt;
  down(idx, begin, end);
  if (l <= begin && end <= r) return seg[idx];
  int mid = (begin + end) >> 1;
  return combine(query(idx << 1, begin, mid, l, r),
                 query((idx << 1) | 1, mid + 1, end, l, r));
}
void debug(int idx, int begin, int end, int l, int r) {
  for (int(i) = int(l); (i) <= int(r); ++(i)) {
    cout << query(idx, begin, end, i, i).val << ", ";
  }
  cout << '\n';
}
long long ar[NMAX];
vector<pair<int, long long>> athis[NMAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  for (int(i) = int(1); (i) <= int(N); ++(i)) cin >> ar[i];
  for (int(i) = int(1); (i) <= int(M); ++(i)) {
    cin >> a >> b >> c;
    athis[b].push_back({a, c});
  }
  build(1, 1, N + 1);
  long long ans = 0;
  for (int(i) = int(1); (i) <= int(N); ++(i)) {
    long long v = query(1, 1, N + 1, 1, i).val;
    update(1, 1, N + 1, i + 1, i + 1, v);
    update(1, 1, N + 1, 1, i, -ar[i]);
    for (auto pa : athis[i]) {
      update(1, 1, N + 1, 1, pa.first, pa.second);
    }
  }
  cout << max(ans, query(1, 1, N + 1, 1, N + 1).val);
  return 0;
}
