#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MOD = 1000000007;

int niz[505];
int zvezda[505];
ll dp[505][505];

int n;

int add(int a, int b){
    return (a+b)%MOD;
}

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

int resi(int l, int r){
    if(dp[l][r] != -1){
        return dp[l][r];
    }
    dp[l][r] = 0;
    //cout << l << " " << r << "ovde\n";
    if(l <= r){
        for(int i2=l+1; i2<=r; i2+=4){
            for(int i3=i2+1; i3<=r; i3+=4){
                for(int i4=i3+1; i4<=r; i4+=4){
                    if((niz[l] ^ niz[i2] ^ niz[i3] ^ niz[i4]) == 0){
                        continue;
                    }
                    //if(l == 0 && r == n-1) cout << l << " " << i2 << " " << i3 << " " << i4 << endl;
                    ll g = 1;
                    if(i2-l-1) g = mul(g, resi(l+1, i2-1));
                    if(i3-i2-1) g = mul(g, resi(i2+1, i3-1));
                    if(i4-i3-1) g = mul(g, resi(i3+1, i4-1));
                    if(r-i4) g = mul(g, resi(i4+1, r));
                    dp[l][r] = add(dp[l][r], g);
                    //cout << l << " " << r << " " << g << endl;
                }
            }
        }
        return dp[l][r];
    }
    return 0;
}

int Zvezda(int N, int *A[]){
    n = N;
    for(int i=0; i<n; i++){
        niz[i] = A[i+1];
    }
    for(int l=0; l<n; l++){
        for(int r=0; r<n; r++){
            if((r-l+1)%4 == 0) dp[l][r] = -1;
        }
    }

    //cout << resi(4, 7) << "prvo" << endl;
    //return 55;
    return resi(0, n-1);
}

/*int main(){

    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> niz[i];
    }
    cout << Zvezda(n, niz);
    return 0;
}*/