#include <bits/stdc++.h>
using namespace std;
const int NR = 5e6 + 10;
int n, p;
int a[NR];
int x, y, z;
int main()
{
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 j = x; j <= y; j++) {
a[j] += z;
}
}
sort(a + 1, a + 1 + n);
cout << a[1];
return 0;
}
2 个 TLE
有注释应该看得懂