#include <bits/stdc++.h>
using namespace std;
template <class T>
void splitstr(const string &s, vector<T> &out) {
  istringstream in(s);
  out.clear();
  copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
static void redirect(int argc, const char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  if (argc > 1) {
    static filebuf f;
    f.open(argv[1], ios::in);
    cin.rdbuf(&f);
    if (!cin) {
      cerr << "Failed to open '" << argv[1] << "'" << endl;
      exit(1);
    }
  }
  if (argc > 2) {
    static filebuf f;
    f.open(argv[2], ios::out | ios::trunc);
    cout.rdbuf(&f);
    if (!cout) {
      cerr << "Failed to open '" << argv[2] << "'" << endl;
    }
  }
}
constexpr int BITS = 30;
int main(int argc, const char **argv) {
  redirect(argc, argv);
  int N;
  cin >> N;
  vector<int> a(N);
  vector<vector<int> > bpos(BITS);
  vector<pair<int, int> > ordered(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    ordered[i] = pair<int, int>(a[i], i);
    for (int j = 0; j < BITS; j++)
      if (a[i] & (1 << j)) bpos[j].push_back(i);
  }
  for (int j = 0; j < BITS; j++) bpos[j].push_back(N);
  sort(begin(ordered), end(ordered));
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    int r = i;
    int cur = a[i];
    vector<int> addbit;
    for (int j = 0; j < BITS; j++)
      if (!(cur & (1 << j)))
        addbit.push_back(*upper_bound(begin(bpos[j]), end(bpos[j]), i));
    sort(begin(addbit), end(addbit));
    addbit.push_back(N);
    addbit.resize(unique(begin(addbit), end(addbit)) - addbit.begin());
    int nxt = 0;
    while (r < N) {
      int s = addbit[nxt++];
      int stop = s;
      auto stoppos =
          lower_bound(begin(ordered), end(ordered), pair<int, int>(cur, i));
      if (stoppos != ordered.end() && stoppos->first == cur &&
          stoppos->second < stop)
        stop = stoppos->second;
      ans += stop - r;
      if (s < N) cur |= a[s];
      r = s;
    }
  }
  cout << ans << '\n';
  return 0;
}
