#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD =1e9 +7;
const int MAXN =1005;
ll pow2(ll x) {
ll res =1, base =2;
while (x) {
if (x &1) res = res * base % MOD;
base = base * base % MOD;
x >>=1;
}
return res;
}
ll comb[MAXN][MAXN];
void f(int n) {
for (int i =0; i <= n; i++) {
comb[i][0] =1;
for (int j =1; j <= i; j++) {
comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % MOD;
}
}
}
int main() {
freopen("01.in","r",stdin);
freopen("01.out","w",stdout);
int n;
cin >> n;
vector<int> b(n);
for (int i =0; i < n; i++) cin >> b[i];
f(n);
int cnt0 = count(b.begin(), b.end(),0);
int cnt1 = n - cnt0;
ll ans =0;
for (int t =0; t <= n; t++) {
ll exponent =1LL * cnt0 * (n - t) +1LL * cnt1 * t;
ll term = comb[n][t] * pow2(exponent) % MOD;
ans = (ans + term) % MOD;
}
cout << ans << endl;
return 0;
}