RT
#include <bits/stdc++.h>
using namespace std;
const int N = 5e7+1;
int n, p, x, y, z, a[N], minx;
int main() {
ios :: sync_with_stdio (false);
cin >> n >> p;
for (int i = 1; i <= n; i ++ )
cin >> a[i], a[i] -= a[i - 1];
for (int i = 1; i <= p; i ++ ) {
cin >> x >> y >> z;
a[x] += z;
a[y + 1] -= z;
}
minx = a[1];
for (int i = 2; i <= n; i ++ ) {
a[i] += a[i - 1];
minx = min (minx, a[i]);
}
cout << minx << endl;
return 0;
}