import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(ulong[]);
    ulong x;
    size_t i, j;
    long r;
    while (j < N) {
        if (j < N && !(x&AS[j])) {
            x |= AS[j];
            r += j-i+1;
            ++j;
        } else {
            do {
                x ^= AS[i++];
            } while (i < N && x&AS[j]);
            x |= AS[j];
            r += j-i+1;
            ++j;
        }
    }
    writeln(r);
}