#include #include #include using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin>>n; vectorA(n); rep(i,n)cin>>A[i]; ll ans=0; rep(i,28){ ll C=(ll)n*(n+1)/2,e=0; rep(j,n){ if(A[j]>>i&1){ C-=e*(e+1)/2; e=0; }else{ e++; } } C-=e*(e+1)/2; C*=(1<