#include #include using namespace std; using namespace atcoder; using ll=long long; struct S{ ll sum,val,len; int p; S(){} S(ll sum,ll val,ll len,int p):sum(sum),val(val),len(len),p(p){}; }; S op(S x,S y){ S res; res.sum=x.sum+y.sum+x.val*y.len; if(x.p==1)res.sum+=y.len; res.val=x.val+y.val; if(x.p==1)res.val++; res.len=x.len+y.len; res.p=y.p; return res; } S e(){ return S(0,0,0,0); } int main() { int n,q; cin>>n>>q; vector a(n); for(int i=0;i>a[i]; vector v(n); for(int i=0;i st(v); while(q--){ int l,r; cin>>l>>r; cout<