#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
ll dp[1000][1000];
ll mod=1000000007;

int Zvezda(int N,int *A)
{
    ll nule=0;
    ll jedinice=0;
    ll vrati=0;
    ll dp[1000][1000];
    for(int i=1;i<=N;i++){
        if(A[i]==1)jedinice++;
        else nule++;
    }
    for(int i=1;i<=100;i++){
        for(int j=0;j<=100;j++){
            if(i==j || j==0)dp[i][j]=1;
            else if(j==1)dp[i][j]=i;
            else{
                dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
                dp[i][j]%=mod;
            }
        }
    }

    for(int i=1;i<=nule;i++){
        vrati+=dp[jedinice][3];
        vrati%=mod;
    }
    for(int i=1;i<=jedinice;i++){
        vrati+=dp[nule][3];
        vrati%=mod;
    }
    return vrati;
}