Problem:
Score : 800 points

Problem Statement

The beauty of a sequence a of length n is defined as a_1 \oplus \cdots \oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).

You are given a sequence A of length N.
Snuke will insert zero or more partitions in A to divide it into some number of non-empty contiguous subsequences.

There are 2^{N-1} possible ways to insert partitions.
How many of them divide A into sequences whose beauties are all equal? Find this count modulo 10^{9}+7.

Constraints

All values in input are integers.

1 \leq N \leq 5 \times 10^5

0 \leq A_i < 2^{20}

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \ldots A_{N}

Output

Print the answer.

Sample Input 1

3
1 2 3

Sample Output 1

3

Four ways of dividing A shown below satisfy the condition. The condition is not satisfied only if A is divided into (1),(2),(3).

(1,2,3)

(1),(2,3)

(1,2),(3)

Sample Input 2

3
1 2 2

Sample Output 2

1

Sample Input 3

32
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Sample Output 3

147483634

Find the count modulo 10^{9}+7.

Sample Input 4

24
1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2

Sample Output 4

292

Solution in Rust (1.15.1) (judge verdict: Wrong Answer)

const MOD: u64 = 1e9 as u64 + 7;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let mut map: Vec<Vec<usize>> = vec![vec![]; 1 << 20];
    let mut sum = 0;
    for i in 0..n {
        sum ^= a[i];
        map[sum].push(i);
    }

    let mut vis = vec![false; 1 << 20];

    let mut ans = 0;
    let mut cur = 0;
    let mut count = 0;
    for i in 0..n {
        cur ^= a[i];
        if vis[cur] {
            continue;
        }
        vis[cur] = true;
        count += 1;

        let sum = cur;
        let mut dp = (1, 1);
        let mut pos = i;
        let x = [0, sum];
        while pos < n {
            for &x in x.iter() {
                let next = match map[x].binary_search(&(pos + 1)) {
                    Ok(idx) => idx,
                    Err(idx) => idx,
                };
                if next == map[x].len() {
                    if pos == n - 1 {
                        ans += dp.0;
                    }
                    pos = n;
                    break;
                }
                let tmp = (dp.0 + dp.1) % MOD;
                dp = (tmp, tmp);
                pos = map[x][next];
            }
        }
    }

    if sum == 0 {
        ans = (ans + MOD - count + 1) % MOD;
    } else {
        ans += 1;
    }
    println!("{}", ans % MOD);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}