import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }

void solve() {
    int n = read();
    int[] a = reads();

    bool can(int l, int r) {
        if (r >= n) return false;
        if (l == r) return true;
        bool[] b = new bool[22];

        foreach (i; a[l..r+1]) {
            foreach (j; 0..22){
                if (i & (1 << j)) {
                    if (b[j]) return false;
                    b[j] = true;
                }
            }
        }
        return true;
    }

    int r;
    int ans;
    foreach (l; 0..n) {
        while (can(l, r))
            r++;
        debug writeln(l, " " ,r);
        ans += r - l;
        if (l+1 == r) {
            continue;
        }
        r--;
    }
    writeln(ans);
}


void main() {
    solve();
    readln;
}