#include <bits/stdc++.h>
const int N = 2e5 + 5;
int n, val[N];
namespace utils {
template <class T>
inline void apn(T &x, const T y) {
  x = x < y ? x : y;
}
template <class T>
inline void apx(T &x, const T y) {
  x = x > y ? x : y;
}
inline int nxi() {
  int x = 0;
  char c;
  while (((c = getchar()) > '9' || c < '0') && c != '-')
    ;
  const bool f = (c == '-') && (c = getchar());
  while (x = x * 10 - 48 + c, (c = getchar()) >= '0' && c <= '9')
    ;
  return f ? -x : x;
}
}  // namespace utils
using namespace utils;
int main() {
  n = nxi();
  long long ans = 0;
  for (int l = 1, s = 0, i = 1; i <= n; ++i) {
    val[i] = nxi();
    while (s & val[i]) s ^= val[l++];
    s |= val[i];
    ans += i - l + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
