import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string, core.stdc.stdlib;

void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0].to!int;
    auto L = s[1];
    auto R = s[2];
    auto A = readln.split.map!(to!long).array;

    immutable int M = 61;
    auto possible = new int[][](M+1);

    void rec(int l, int r, int keta, int si) {
        if (keta < 0) return;
        auto B = A[l..r].map!(a => (a & (1L << keta)) > 0).array;
        auto x = B.dup.uniq.array.length;
        if (x > 2) {
            writeln(0);
            exit(0);
        } else if (x == 2) {
            possible[si-1] ~= B.front;
            int cut = B.countUntil(!B.front).to!int;
            rec(l, l+cut, keta-1, si+1);
            rec(l+cut, r, keta-1, si+1);
        } else {
            possible[si-1] ~= 2;
            rec(l, r, keta-1, si+1);
        }
    }

    rec(0, N, M-1, 1);

    long solve(long ub) {
        auto dp = new long[][](M+1, 2);
        dp[0][0] = 1;

        foreach (i; 0..M) {
            auto hoge = possible[i].dup.sort().uniq.array;
            int[] nexts;
            if (hoge.canFind(0) && hoge.canFind(1))  {
                writeln(0);
                exit(0);
            } else if (hoge.canFind(0)) {
                nexts ~= 0;
            } else if (hoge.canFind(1)) {
                nexts ~= 1;
            } else {
                nexts ~= [0, 1];
            }
            bool b = (ub & (1L << (M - i - 1))) > 0;
            foreach (under; 0..2) {
                foreach (next; nexts) {
                    if (!under && next && !b) continue;
                    dp[i+1][under||(next<b)] += dp[i][under];
                }
            }
        }
        return dp[M].sum;
    }

    auto ansR = solve(R);
    auto ansL = L == 0 ? 0 : solve(L - 1);
    writeln(ansR - ansL);
}