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 C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ll long long

using namespace std;

const int MOD = 1e9 + 7;
const int MAXN = 10000010;

int sum0[MAXN];
int sum[MAXN];
int pref[MAXN];
int last[MAXN];

int add(int a, int b) {
    a += b;
    if (a >= MOD) return a - MOD;
    if (a < 0) return a + MOD;
    return a;
}

int mul(int a, int b) {
    return ((ll) a * b % MOD); 
}

int main() {
    ios_base::sync_with_stdio(false);
    REP(i, MAXN) sum0[i] = 1, last[i] = -1;
    sum[0] = 1;

    int n;
    cin >> n;

    int x = 0;
    REP(i, n) {
        int y;
        cin >> y;

        if (i > 0) pref[i] += pref[i - 1];

        x ^= y;
        if (x == 0) {
            pref[i]++;
            
            if (i == n - 1) {
                //assert(0);
                int out = 0;
                REP(i, MAXN) out = add(out, sum[i]);
                cout << out << "\n";
                return 0;
            }

            sum[0] = add(sum[0], sum[0]);
        } else {
            int num = pref[i];
            if (last[x] >= 0) num -= pref[last[x]];

            sum0[x] = add(sum0[x], mul(sum[x], num));
            sum[x] = add(sum[x], sum0[x]);
            last[x] = i;

            if (i == n - 1) {
                cout << sum0[x] << "\n";
                return 0;
            }
        }
    }


    return 0;
}