#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a struct SegmentTree{ using F = function; int n; F f; T ti; vector dat; SegmentTree(){}; SegmentTree(F f,T ti):f(f),ti(ti){} void init(int n_){ n=1; while(n &v){ int n_=v.size(); init(n_); for(int i=0;i>=1) dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]); } T query(int a,int b){ T vl=ti,vr=ti; for(int l=a+n,r=b+n;l>=1,r>>=1) { if(l&1) vl=f(vl,dat[l++]); if(r&1) vr=f(dat[--r],vr); } return f(vl,vr); } }; struct FastIO{ FastIO(){ cin.tie(0); ios::sync_with_stdio(0); } }fastio_beet; //INSERT ABOVE HERE signed main(){ int n,q; cin>>n>>q; vector as(n); for(int i=0;i>as[i]; vector ls(q),rs(q),xs(q); for(int i=0;i>t; assert(t==1); cin>>ls[i]>>rs[i]>>xs[i]; ls[i]--; } vector ord(n+q); iota(ord.begin(),ord.end(),0); auto comp=[&](int a,int b){ int u=(av; }; sort(ord.begin(),ord.end(),comp); using ll = long long; vector ans(q); auto f=[](ll a,ll b){return a+b;}; SegmentTree num(f,0),sum(f,0); num.build(vector(n,0)); sum.build(vector(n,0)); for(int x:ord){ if(x