#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 1000000007;
const int sz = 1 << 20;

ll modpow(ll a, ll b, ll m = mod) {
	ll ans = 1;
	a %= m;
	while (b) {
		if (b & 1) ans = ans * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return ans;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	int now = 0;
	vector<int> a(n), x(n), zero(n);
	vector<vector<int>> pl(sz, vector<int>());
	rep(i, n) {
		cin >> a[i];
		now ^= a[i];
		x[i] = now;
		int pre = 0;
		if (i) pre = zero[i - 1];
		if (now == 0) pre++;
		zero[i] = pre;
		pl[now].pb(i);
	}
	if (now == 0) {
		ll ans = modpow(2, pl[0].size() - 1);
		for (int num = 1; num < sz; num++) {
			vector<int> vec;
			int s = pl[num].size();
			if (s == 0) continue;
			rep(i, s - 1) {
				vec.pb(1);
				vec.pb(zero[pl[num][i + 1]] - zero[pl[num][i]]);
			}
			vec.pb(1);
			vector<vector<ll>> dp(2 * s, vector<ll>(2));
			dp[0][0] = 1;
			rep(i, 2 * s - 1) {
				dp[i + 1][0] += dp[i][0];
				if (i % 2 == 1) {
					dp[i + 1][0] += dp[i][1] * vec[i];
				}
				dp[i + 1][1] += dp[i][1];
				if (i % 2 == 0) {
					dp[i + 1][1] += dp[i][0] * vec[i];
				}
				dp[i + 1][0] %= mod;
				dp[i + 1][1] %= mod;
			}
			ans += dp[2 * s - 1][1];
		}
		ans %= mod;
		cout << ans << '\n';
	}
	else {
		int num = now;
		vector<int> vec;
		int s = pl[num].size();
		rep(i, s - 1) {
			vec.pb(1);
			vec.pb(zero[pl[num][i + 1]] - zero[pl[num][i]]);
		}
		vector<vector<ll>> dp(2 * s - 1, vector<ll>(2));
		dp[0][0] = 1;
		rep(i, 2 * s - 2) {
			dp[i + 1][0] += dp[i][0];
			if (i % 2 == 1) {
				dp[i + 1][0] += dp[i][1] * vec[i];
			}
			dp[i + 1][1] += dp[i][1];
			if (i % 2 == 0) {
				dp[i + 1][1] += dp[i][0] * vec[i];
			}
			dp[i + 1][0] %= mod;
			dp[i + 1][1] %= mod;
		}
		cout << dp[2 * s - 2][0] << '\n';
	}
}
#include <bits/stdc++.h>
using namespace std;

#define task "test"
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define openfile  if (fopen(task ".inp","r")){freopen(task ".inp","r",stdin);freopen(task ".out","w",stdout);}
#define ll long long
#define pii pair <int, int>
#define pll pair <ll, ll>
#define all(c) c.begin(), c.end()
#define pb push_back
#define mp make_pair
#define X first
#define Y second

const int INF = 1E9;
const int MOD = 1E9 + 7;
const int N = 1000 + 10;

int t = 1;

ll n, a, b, c, d;
ll Fact[N], Inv[N], F[N][N];

ll POW(ll n, ll k)
{
    if (k == 1) return n;
    ll tmp = POW(n, k / 2);
    tmp = tmp * tmp % MOD;

    if (k & 1) return tmp * n % MOD;
    return tmp;
}

void Input()
{
    cin >> n >> a >> b >> c >> d;
}

void Prepare()
{
    Fact[0] = Inv[0] = Fact[1] = Inv[1] = 1;
    for (int i = 2; i <= n; i++) Fact[i] = Fact[i - 1] * (ll) (i) % MOD;
    for (int i = 2; i <= n; i++) Inv[i] = POW(Fact[i], MOD - 2);
}

ll Comb(ll n, ll k)
{
    if (n < k) return 0;
    return Fact[n] * Inv[k] % MOD * Inv[n - k] % MOD;
}

void Solve()
{
    F[a - 1][0] = 1;

    for (int i = a; i <= b; i++)
        for (int j = 0; j <= n; j++) {
            F[i][j] = F[i - 1][j];
            //cout << "Pre : " << F[i][j] <<" - > ";
            for (int k = c; k <= d && i * k <= j; k++) {
                F[i][j] += F[i - 1][j - i * k] * Comb(j, j - i * k) % MOD * Fact[i * k] % MOD * POW(Inv[i], k) % MOD * Inv[k] % MOD;
                F[i][j] %= MOD;
              //  if (i == 1 && j == 3) cout << F[i][j] << " " << k << endl;
            }
          //  cout << i << " " << j << " " << F[i][j] << endl;
        }
    cout << F[b][n];
}

int main()
{
    openfile;
    // cin >> t;
    while (t--) {
        Input();
        Prepare();
        Solve();
    }
}



