#include <bits/stdc++.h>
using namespace std;
long long int n;
int a[202020];
long long int ans = 0;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  ans = (n * (n - 1)) / 2;
  long long int lt = 0, rt = 0;
  a[0] = a[n + 1] = 1000000009;
  for (int i = 1; i <= n; i++) {
    if (a[i] == a[i - 1]) {
      lt = 0;
      rt--;
    } else {
      lt = rt = 0;
      for (int j = i - 1; a[j] < a[i] && ((a[i] | a[j]) == a[i]); j--, lt++)
        ;
      for (int j = i + 1; (a[i] | a[j]) == a[i]; j++, rt++)
        ;
    }
    ans -= (lt + 1) * (rt + 1);
    ans++;
  }
  cout << ans << "\n";
  return 0;
}
