#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, now[30] = {0}, tt[200010LL] = {0}, ma[200010LL] = {0},
    po2[30] = {0};
int main() {
  int N, n, cntnow, i, j, x;
  read(N);
  po2[0] = 1;
  for (i = (1); i < (30); i++) po2[i] = po2[i - 1] << 1;
  for (n = (1); n <= (N); n++) {
    read(x);
    cntnow = 0;
    for (i = (0); i < (30); i++)
      if (po2[i] & x) {
        cntnow++;
        for (j = (n - 1); j > (now[i]); j--) {
          tt[j]++;
          if (tt[j] == ma[j] + 1) sumnow++;
        }
        now[i] = n;
      } else if (x < po2[i])
        break;
    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;
    ans += sumnow;
  }
  printf("%lld\n", ans);
END:
  getchar(), getchar();
  return 0;
}
