#ifndef call_from_test #include using namespace std; using Int = long long; #endif //BEGIN CUT HERE template struct SparseTable{ using F = function; vector< vector > dat; vector ht; const F f; SparseTable(){} SparseTable(F f):f(f){} void build(const vector &v){ int n=v.size(),h=1; while((1<(n)); ht.assign(n+1,0); for(int j=2;j<=n;j++) ht[j]=ht[j>>1]+1; for(int j=0;j a(n),x(m); for(int i=0;i st(f); st.build(a); map ans; for(int i=0;i>1; if(st.query(i,m)!=pre) r=m; else l=m; } ans[pre]+=l-pl; pre=st.query(i,r); } ans[lst]+=n-l; } for(int i=0;i