#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll a[200002];
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  for (ll i = 1; i <= n; ++i) cin >> a[i];
  ll ans = (n * (n - 1)) / 2;
  ll lhs = 0, rhs = 0;
  a[0] = a[n + 1] = 1e12;
  for (ll i = 1; i <= n; ++i) {
    if (a[i] == a[i - 1]) {
      lhs = 0;
      --rhs;
    } else {
      lhs = 0;
      rhs = 0;
      for (ll j = i - 1; a[j] < a[i] && ((a[i] | a[j]) == a[i]); --j, lhs++)
        ;
      for (ll j = i + 1; a[j] <= a[i] && ((a[i] | a[j]) == a[i]); ++j, rhs++)
        ;
    }
    ans -= (lhs + 1) * (rhs + 1);
    ++ans;
  }
  cout << ans << '\n';
  return 0;
}
