func_code_string: #include <bits/stdc++.h>   using namespace std;   int const N = int(2e5) + 7;   int const mod = int(1e9) + 7;   int a[N];   int ra[N], le[N];   int raB[N][31], leB[N][31];   int main() {     ios_base::sync_with_stdio(false);     ifstream in( input.txt );     int n;     cin >> n;     vector<int> st;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       while (st.size() > 0 && a[st.back()] <= a[i]) {         int ind = st.back();         st.pop_back();         int ll = 0;         if (st.size() > 0) {           ll = st.back();         }         le[ind] = ll;         ra[ind] = i;       }       st.push_back(i);       for (int j = 0; j <= 30; ++j) {         if (a[i] & (1 << j)) {           leB[i][j] = i;         } else {           leB[i][j] = leB[i - 1][j];         }       }     }     while (st.size() > 0) {       int ind = st.back();       st.pop_back();       int ll = 0;       if (st.size() > 0) {         ll = st.back();       }       le[ind] = ll;       ra[ind] = n + 1;     }     for (int i = n; i >= 0; --i) {       for (int j = 0; j <= 30; ++j) {         if (a[i] & (1 << j)) {           raB[i][j] = i;         } else {           raB[i][j] = raB[i + 1][j];         }       }     }     long long ans = 0;     for (int i = 1; i <= n; ++i) {       int indl = 0, indr = n + 1;       for (int j = 30; j >= 0; --j) {         if (!(a[i] & (1 << j)) && (leB[i - 1][j])) {           indl = max(indl, leB[i - 1][j]);         }       }       for (int j = 30; j >= 0; --j) {         if (!(a[i] & (1 << j)) && (raB[i + 1][j])) {           indr = min(indr, raB[i + 1][j]);         }       }       long long am1 = max(0, indl - le[i]);       long long am2 = max(0, i - max(indl, le[i]));       long long am3 = max(0, min(ra[i], indr) - i);       long long am4 = max(0, ra[i] - indr);       long long del = am1 * (am3 + am4) + am2 * am4;       ans += am1 * (am3 + am4) + am2 * am4;     }     cout << ans;     return 0;   }   