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;
const int maxN = 200005;
const long long oo = 10000000000000000LL;
int n, m, c[maxN];
struct Region {
  int st, en, d;
} p[maxN];
struct TmaxV {
  long long val, del;
  TmaxV() {}
  TmaxV(long long a, long long b) : val(a), del(b) {}
};
struct Tnode {
  long long add, best;
  TmaxV maxV;
} tree[4 * maxN];
long long sum[maxN], ans;
void Readln() {
  scanf("%d%d\n", &m, &n);
  for (int i = 1; i <= m; i++) scanf("%d\n", &c[i]);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d\n", &p[i].st, &p[i].en, &p[i].d);
  }
}
bool cmp(Region a, Region b) {
  return a.st < b.st || a.st == b.st && a.en < b.en;
}
TmaxV getmax(const TmaxV &a, const TmaxV &b) {
  if (a.val + a.del > b.val + b.del) return a;
  return b;
}
void down(int root) {
  if (tree[root].add == 0) return;
  tree[root * 2].add += tree[root].add;
  tree[root * 2].maxV.val += tree[root].add;
  tree[root * 2].best += tree[root].add;
  tree[root * 2 + 1].add += tree[root].add;
  tree[root * 2 + 1].maxV.val += tree[root].add;
  tree[root * 2 + 1].best += tree[root].add;
  tree[root].add = 0;
}
void inittree(int root, int lef, int rig) {
  if (lef == rig) {
    if (lef > 0)
      tree[root].maxV.val = -oo;
    else
      tree[root].maxV.val = 0;
    tree[root].best = tree[root].maxV.val;
    tree[root].maxV.del = sum[lef];
    return;
  }
  int mid = (lef + rig) / 2;
  inittree(root * 2, lef, mid);
  inittree(root * 2 + 1, mid + 1, rig);
  tree[root].maxV = getmax(tree[root * 2].maxV, tree[root * 2 + 1].maxV);
  tree[root].best = max(tree[root * 2].best, tree[root * 2 + 1].best);
}
void addtree(int root, int lef, int rig, int lo, int hi, int val) {
  if (rig < lo || hi < lef) return;
  if (lo <= lef && rig <= hi) {
    tree[root].add += val;
    tree[root].maxV.val += val;
    tree[root].best += val;
    return;
  }
  down(root);
  int mid = (lef + rig) / 2;
  addtree(root * 2, lef, mid, lo, hi, val);
  addtree(root * 2 + 1, mid + 1, rig, lo, hi, val);
  tree[root].maxV = getmax(tree[root * 2].maxV, tree[root * 2 + 1].maxV);
  tree[root].best = max(tree[root * 2].best, tree[root * 2 + 1].best);
}
TmaxV asktree1(int root, int lef, int rig, int lo, int hi) {
  if (rig < lo || hi < lef) return TmaxV(-oo, -oo);
  if (lo <= lef && rig <= hi) return tree[root].maxV;
  down(root);
  int mid = (lef + rig) / 2;
  return getmax(asktree1(root * 2, lef, mid, lo, hi),
                asktree1(root * 2 + 1, mid + 1, rig, lo, hi));
}
long long asktree2(int root, int lef, int rig, int lo, int hi) {
  if (rig < lo || hi < lef) return -oo;
  if (lo <= lef && rig <= hi) return tree[root].best;
  down(root);
  int mid = (lef + rig) / 2;
  return max(asktree2(root * 2, lef, mid, lo, hi),
             asktree2(root * 2 + 1, mid + 1, rig, lo, hi));
}
void inserttree(int root, int lef, int rig, int pla, long long val) {
  if (rig < pla || pla < lef) return;
  if (lef == rig && rig == pla) {
    tree[root].maxV.val = max(tree[root].maxV.val, val);
    tree[root].best = max(tree[root].best, val);
    return;
  }
  down(root);
  int mid = (lef + rig) / 2;
  inserttree(root * 2, lef, mid, pla, val);
  inserttree(root * 2 + 1, mid + 1, rig, pla, val);
  tree[root].maxV = getmax(tree[root * 2].maxV, tree[root * 2 + 1].maxV);
  tree[root].best = max(tree[root * 2].best, tree[root * 2 + 1].best);
}
void getans(int root, int lef, int rig) {
  if (lef == rig) {
    ans = max(ans, tree[root].maxV.val);
    return;
  }
  down(root);
  int mid = (lef + rig) / 2;
  getans(root * 2, lef, mid);
  getans(root * 2 + 1, mid + 1, rig);
}
void Solve() {
  sort(p + 1, p + 1 + n, cmp);
  for (int i = 1; i <= m; i++) sum[i] = sum[i - 1] + c[i];
  inittree(1, 0, m);
  for (int i = 1; i <= n; i++) {
    addtree(1, 0, m, p[i].en, m, p[i].d);
    TmaxV tmp = asktree1(1, 0, m, p[i].st, p[i].en - 1);
    inserttree(1, 0, m, p[i].en, tmp.val - sum[p[i].en] + tmp.del + p[i].d);
    long long tp = asktree2(1, 0, m, 0, p[i].st - 1);
    inserttree(1, 0, m, p[i].en, tp - sum[p[i].en] + sum[p[i].st - 1] + p[i].d);
  }
  ans = 0;
  getans(1, 0, m);
  printf("%I64d\n", ans);
}
int main() {
  Readln();
  Solve();
  return 0;
}