#include #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; int main() { int n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; ll ans = 0; rep(b, 28) { ll now = (ll)n*(n+1)/2; int c = 0; rep(i, n) { if (~a[i]>>b&1) { c++; now -= c; } else c = 0; } ans += now*(1ll<