func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   int pre[N][32], suf[N][32], mx[N][32];   int n, a[N];   long long ans;   void init() {     for (int i = 0; i < n; i++) mx[i][0] = i;     for (int i = 1; (1 << i) < N; i++) {       for (int j = 0; j < n; j++) {         mx[j][i] = (a[mx[j][i - 1]] > a[mx[j + (1 << (i - 1))][i - 1]]                         ? mx[j][i - 1]                         : mx[j + (1 << (i - 1))][i - 1]);       }     }   }   int query(int l, int r) {     int d = (int)(log((double)r - l + 1) / log(2.0));     return a[mx[l][d]] > a[mx[r - (1 << d) + 1][d]] ? mx[l][d]                                                     : mx[r - (1 << d) + 1][d];   }   void dfs(int l, int r) {     if (l > r) return;     int x = query(l, r);     int L = l, R = r;     int fl = 0, fr = 0;     for (int i = 0; i < 32; i++) {       if (!((a[x] >> i) & 1) && pre[x][i] != -1 && pre[x][i] >= l) {         fl = 1;         L = max(L, pre[x][i]);       }       if (!((a[x] >> i) & 1) && suf[x][i] != -1 && suf[x][i] <= r) {         fr = 1;         R = min(R, suf[x][i]);       }     }     L -= !fl;     R += !fr;     ans -= 1LL * (x - L) * (R - x);     dfs(l, x - 1);     dfs(x + 1, r);   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       for (int j = 0; j < 32; j++) {         if (!((a[i] >> j) & 1)) {           if (i)             pre[i][j] = pre[i - 1][j];           else             pre[i][j] = -1;         } else           pre[i][j] = i;       }     }     for (int i = n - 1; i >= 0; i--) {       for (int j = 0; j < 32; j++) {         if (!((a[i] >> j) & 1)) {           if (i < n - 1)             suf[i][j] = suf[i + 1][j];           else             suf[i][j] = -1;         } else           suf[i][j] = i;       }     }     init();     ans = 1LL * n * (n + 1) / 2;     dfs(0, n - 1);     printf( %I64d n , ans);     return 0;   }   