#include<bits/stdc++.h>
#define ll long long
#define M 1000000007

using namespace std;

int a[500];

bool moze(int i, int j, int k, int l)
{
    return((a[i]^a[j]^a[k]^a[l])==1);
}

ll resi(int poc, int kraj, int n)
{
    //cout<<poc<<" "<<kraj<<" "<<n<<endl;
    if(n==4)
    {
        if(moze(poc,poc+1,poc+2,poc+3))
            return 1;
        return 0;
    }

    ll ret=0;
    if(moze(poc,poc+1,poc+2,poc+3))
        ret=(ret+resi(poc+4, kraj, n-4))%M;
    if(moze(kraj,poc,poc+1,poc+2))
        ret=(ret+resi(poc+3, kraj-1, n-4))%M;
    if(moze(kraj-1,kraj,poc,poc+1))
        ret=(ret+resi(poc+2, kraj-2, n-4))%M;
    if(moze(kraj-2,kraj-1,kraj,poc))
        ret=(ret+resi(poc+1, kraj-3, n-4))%M;
    return ret;
}

int Zvezda(int N, int* A) {

    for(int i=0;i<=N;i++)
        a[i]=A[i];
	ll sol=resi(1,N,N);
	return sol;
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);

    int N;
    cin >> N;

    int *A = new int[N+1];
    for(int i = 1; i <= N; i++)
        cin >> A[i];

    int res = Zvezda(N, A);

    //cout<<moze(0,1,2,3);

    cout << res << endl;

    delete[] A;

    return 0;

    return 0;
}