#include using namespace std; using ll=long long; using pii=pair; #define all(a) a.begin(),a.end() #define pb push_back #define sz(a) ((int)a.size()) const int N=100005; int n,m,a[N]; signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); cin >> n >> m; for(int i=0; i> a[i]; ll res=0; for(int i=0; i> f >> b >> w; int j=lower_bound(a,a+n,f)-a; if(j=0) mn=min(mn,f-a[j]); res+=max(b,w-mn); } cout << res << "\n"; }