#include <bits/stdc++.h>
using namespace std;
const int Maxn = 200005;
const int Maxl = 20;
int table[Maxl][Maxn];
int tableor[Maxl][Maxn];
int numlog[Maxn];
int n, a[Maxn];
void buildTable() {
  numlog[1] = 0;
  for (int i = 2; i <= n; i++) {
    numlog[i] = numlog[i >> 1] + 1;
  }
  for (int i = 0; i <= numlog[n]; i++) {
    int curlen = 1 << i;
    for (int j = 1; (j + curlen - 1) <= n; j++) {
      if (i == 0) {
        table[i][j] = j;
        continue;
      } else {
        if (a[table[i - 1][j]] >= a[table[i - 1][j + (curlen >> 1)]]) {
          table[i][j] = table[i - 1][j];
        } else {
          table[i][j] = table[i - 1][j + (curlen >> 1)];
        }
      }
    }
  }
}
void buildTableOr() {
  for (int i = 0; i <= numlog[n]; i++) {
    int curlen = 1 << i;
    for (int j = 1; (j + curlen - 1) <= n; j++) {
      if (i == 0) {
        tableor[i][j] = a[j];
        continue;
      } else {
        tableor[i][j] = tableor[i - 1][j] | tableor[i - 1][j + (curlen >> 1)];
      }
    }
  }
}
int getMaxIndex(int l, int r) {
  int curlog = numlog[r - l + 1];
  if (a[table[curlog][l]] >= a[table[curlog][r - (1 << curlog) + 1]]) {
    return table[curlog][l];
  } else {
    return table[curlog][r - (1 << curlog) + 1];
  }
}
int RMQ(int l, int r) { return a[getMaxIndex(l, r)]; }
int getOr(int l, int r) {
  int curlog = numlog[r - l + 1];
  return (tableor[curlog][l] | tableor[curlog][r - (1 << curlog) + 1]);
}
int binary_search(int gst, int st, int end, int cur_or) {
  while (st + 1 < end) {
    int mid = (st + end) / 2;
    int g = getOr(gst, mid);
    if (g > cur_or)
      end = mid;
    else
      st = mid;
  }
  int g = getOr(gst, end);
  if (g == cur_or)
    return end;
  else {
    return st;
  }
}
int get() {
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    int cur_or = a[i];
    int M = a[i];
    for (int j = i; j <= n; j++) {
      cur_or |= a[j];
      M = max(M, a[j]);
      if (cur_or > M) {
        ret++;
      }
    }
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  buildTable();
  buildTableOr();
  long long ans = 0;
  for (int i = n; i >= 1; i--) {
    int cur_or = a[i];
    int st = i;
    int end = binary_search(i, i, n, cur_or);
    int idx = getMaxIndex(st, end);
    if (a[idx] < cur_or) {
      ans += (long long)end - st + 1;
    } else {
      ans += (long long)idx - st;
    }
    while (end <= n) {
      st = end + 1;
      if (st > n) break;
      cur_or = cur_or | a[st];
      end = binary_search(i, st, n, cur_or);
      idx = getMaxIndex(st, end);
      if (a[idx] < cur_or)
        ans += (long long)end - st + 1;
      else
        ans += (long long)idx - st;
    }
  }
  cout << ans << endl;
  return 0;
}
