#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) using ll = long long; constexpr int inf=1e9+7; constexpr ll longinf=1LL<<60 ; constexpr ll mod=1e9+7 ; struct S { int num; ll sum; }; struct F { int num; ll sum; }; S op(S l, S r) { return S{l.num + r.num, l.sum + r.sum}; } S e() { return S{0, 0}; } S mapping(F l, S r) { return l.num == -1 ? r : S{l.num, l.sum}; } F composition(F l, F r) { return l; } F id() { return F{-1, 0}; } int k; bool g(S a){ return a.num <=k; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n, q; cin>>n>>q; vector vs(n); rep(i,n){ int x; cin>>x; vs[i] = {1, x}; } atcoder::lazy_segtree seg(vs); while(q--){ int t, l, r; cin>>t>>l>>r; --l; k = l; int l2 = seg.max_right(0); k = r; int r2 = seg.max_right(0); if(t == 1){ ll sum = seg.prod(l2, r2).sum; seg.apply(l2, r2, {0, 0}); seg.apply(r2-1, r2, {1, sum}); } else { cout<