#include <bits/stdc++.h>
int CH, NEG;
template <typename TP>
inline void read(TP& ret) {
  ret = NEG = 0;
  while (CH = getchar(), CH < '!')
    ;
  if (CH == '-') NEG = true, CH = getchar();
  while (ret = ret * 10 + CH - '0', CH = getchar(), CH > '!')
    ;
  if (NEG) ret = -ret;
}
long long ans = 0;
int sumnow = 0;
int now[30] = {0};
int tt[200010LL] = {0}, ma[200010LL] = {0};
inline void calc(int x, int n) {
  int cntnow = 0, i, j;
  for (i = (0); i <= (29); i++) {
    if ((1 << i) & x) {
      cntnow++;
      for (j = (n - 1); j > (now[i]); j--) {
        tt[j]++;
        if (tt[j] == ma[j] + 1) sumnow++;
      }
      now[i] = n;
    }
  }
  tt[n] = ma[n] = cntnow;
  for (i = (n - 1); i > (0); i--) {
    if (ma[i] < ma[n]) {
      if (ma[n] == tt[i]) sumnow--;
      ma[i] = ma[n];
    } else
      break;
  }
}
int main() {
  int n, i, x;
  scanf("%d", &n);
  for (i = (1); i <= (n); i++) {
    read(x);
    calc(x, i);
    ans += sumnow;
  }
  printf("%lld\n", ans);
END:
  getchar(), getchar();
  return 0;
}
