Problem: You are a car race organizer and would like to arrange some races in Linear Kingdom.

Linear Kingdom has n consecutive roads spanning from left to right. The roads are numbered from 1 to n from left to right, thus the roads follow in the order of their numbers' increasing. There will be several races that may be held on these roads. Each race will use a consecutive subset of these roads. Also, each race will pay some amount of money to you if this race is held. No races overlap in time, so some roads can be used in several races.

Unfortunately, some of the roads are in a bad condition and they need repair. Each road has repair costs associated with it, you are required to pay this cost to repair the road. A race can only take place if all the roads used in the race are renovated. Your task is to repair such roads (possibly all or none) that will maximize your profit. Your profit is defined as the total money you get from the races that are held minus the total money you spent to repair the roads. Note that you may decide not to repair any road and gain zero profit.

Print the maximum profit you can gain.

Input

The first line contains two single-space separated integers, n and m (1 ≤ n, m ≤ 2·105), denoting the number of roads and the number of races, respectively.

Then n lines follow, each line will contain a single non-negative integer not exceeding 109 denoting the cost to repair a road. The costs are given in order from road 1 to road n.

Finally, m lines follow. Each line is single-space-separated triplets of integers. Each triplet will be given as lb, ub, and p (1 ≤ lb ≤ ub ≤ n, 1 ≤ p ≤ 109), which means that the race these three integers describe will use all the roads from lb to ub, inclusive, and if it's held you get p.

Output

Print a single integer denoting the maximum possible profit you can gain.

Please, do not use the %lld specificator to read or write 64-bit integers in C++. It is recommended to use cin, cout stream (also you may use %I64d specificator).

Examples

Input

7 4
3
2
3
2
1
2
3
1 2 5
2 3 5
3 5 3
7 7 5


Output

4


Input

2 1
0
3
1 2 5


Output

2


Input

3 1
10
10
10
1 3 10


Output

0

Note

In the first sample the optimal solution is to repair roads 1, 2, 3, and 7. Three races will take place which nets you 15. The road repair costs 11, hence your profit is 4.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
struct node {
  long long det, f;
  friend node operator+(const node &x, const node &y) {
    node ret;
    ret.det = 0;
    ret.f = max(x.f, y.f);
    return ret;
  }
} tree[200010 << 2];
int st[200010], aim[200010], nxt[200010], d[200010], ln;
int a[200010];
long long sa[200010];
long long f[200010];
int n, m;
void in_edge(int x, int y, int z) {
  aim[ln] = y;
  nxt[ln] = st[x];
  d[ln] = z;
  st[x] = ln++;
}
void push_down(int p) {
  if (tree[p].det) {
    tree[p << 1].det += tree[p].det;
    tree[p << 1].f += tree[p].det;
    tree[(p << 1) + 1].det += tree[p].det;
    tree[(p << 1) + 1].f += tree[p].det;
    tree[p].det = 0;
  }
}
void ins_f(int p, int tl, int tr, int k, long long v) {
  if (tl == tr) {
    tree[p].f = v;
    tree[p].det = 0;
    return;
  }
  push_down(p);
  int m = (tl + tr) >> 1;
  if (k <= m)
    ins_f(p << 1, tl, m, k, v);
  else
    ins_f((p << 1) + 1, m + 1, tr, k, v);
  tree[p] = tree[p << 1] + tree[(p << 1) + 1];
}
void ins(int p, int tl, int tr, int l, int r, long long v) {
  if (tl == l && tr == r) {
    tree[p].det += v;
    tree[p].f += v;
    return;
  }
  push_down(p);
  int m = (tl + tr) >> 1;
  if (l <= m) {
    if (r > m) {
      ins(p << 1, tl, m, l, m, v);
      ins((p << 1) + 1, m + 1, tr, m + 1, r, v);
    } else
      ins(p << 1, tl, m, l, r, v);
  } else
    ins((p << 1) + 1, m + 1, tr, l, r, v);
  tree[p] = tree[p << 1] + tree[(p << 1) + 1];
}
long long ask(int p, int tl, int tr, int l, int r) {
  if (tl == l && tr == r) return tree[p].f;
  push_down(p);
  int m = (tl + tr) >> 1;
  long long ret;
  if (l <= m) {
    if (r > m) {
      ret =
          max(ask(p << 1, tl, m, l, m), ask((p << 1) + 1, m + 1, tr, m + 1, r));
    } else
      ret = ask(p << 1, tl, m, l, r);
  } else
    ret = ask((p << 1) + 1, m + 1, tr, l, r);
  tree[p] = tree[p << 1] + tree[(p << 1) + 1];
  return ret;
}
int main() {
  memset(st, -1, sizeof(st));
  ln = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  sa[0] = 0;
  for (int i = 1; i <= n; i++) sa[i] = sa[i - 1] + a[i];
  for (int i = 0; i < m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    in_edge(v, u, w);
  }
  f[0] = 0;
  ins_f(1, 1, n, 1, f[0]);
  for (int i = 1; i <= n; i++) {
    for (int j = st[i]; j != -1; j = nxt[j]) ins(1, 1, n, 1, aim[j], d[j]);
    long long v = ask(1, 1, n, 1, i);
    f[i] = max(f[i - 1], v - sa[i]);
    if (i < n) ins_f(1, 1, n, i + 1, f[i] + sa[i]);
  }
  printf("%I64d\n", f[n]);
  return 0;
}