#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
int a[N];
int main() {
int n, p, x, y, z;
cin >> n >> p;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= p; i++) {
cin >> x >> y >> z;
for (int i = x; i <= y; i++)
a[i] += z;
}
sort(a + 1, a + n + 1, less<int>());
cout << a[1];
return 0;
}
求助大佬!