#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair P; typedef pair PP; const ll MOD=998244353; const double PI=acos(-1); ll mod_pow(ll x,ll y,ll mod){ ll power=x; ll ret = 1; while(y>0){ if(y&1){ ret = ret*power%mod; } power = power*power%mod; y = y>>1; } return ret; } int main() { int N; cin>>N; vector A(N+1); for(int i=1;i<=N;i++){ cin>>A[i]; } vector> d(30); for(int k=0;k<30;k++){ d[k].push_back(0); for(int i=1;i<=N;i++){ if(((A[i]>>k)&1)==1){ d[k].push_back(i); } } d[k].push_back(N+1); } vector pow2(30,0); pow2[0]=1; for(int i=1;i<30;i++){ pow2[i]=pow2[i-1]*2; } auto f=[&](ll len){ ll res=1LL*len; res*=(len+1); res/=2; return res; }; ll ans=0; for(int k=0;k<30;k++){ ll sumrange=f(N); for(int j=0;j+1c2) continue; int len=c2-c1+1; ll range=f(len); sumrange-=range; } //cout<<"k="<