func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     cin.sync_with_stdio(false);     long long int n;     cin >> n;     vector<long long int> a(n), start(n), end(n);     for (long long int i = 0; i < n; i++) {       cin >> a[i];       start[i] = i;       end[i] = i + 1;     }     for (long long int i = 0; i < n; i++) {       while (start[i] > 0 && (a[i] | a[start[i] - 1]) == a[i]) {         start[i] = start[start[i] - 1];       }     }     for (long long int i = n - 1; i >= 0; i--) {       while (end[i] < n && (a[i] | a[end[i]]) == a[i]) {         end[i] = end[end[i]];       }     }     map<long long int, long long int> last;     long long int good = (n * (n - 1)) / 2;     for (long long int i = 0; i < n; i++) {       if (last.count(a[i]) && last[a[i]] >= start[i]) {         good -= (i - last[a[i]]) * (end[i] - i) - 1;         last[a[i]] = i;         continue;       }       last[a[i]] = i;       good -= (i - start[i] + 1) * (end[i] - i) - 1;     }     cout << good << endl;     return 0;   }   