#include<cstdio>
#include<vector>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
int n,sum,ans;
int num1[100100];
int num[100100];
int dui[500100];
void dfs(int i,int k)
{
num1[i]--;
dui[k]=i;
if (num1[i]==0)
{
int v=i;
for (int j=k;j>=1;j--)
{
if (v<dui[j]&&num1[dui[j]]==0)
return;
}
}
if (k==sum) ans++;
for (int j=1;j<=n;j++)
{
if (num1[j]>0)
{
dfs(j,k+1);
num1[j]++;
dui[k+1]=0;
}
}
}
int main()
{
freopen("asm_formation.in","r",stdin);
freopen("asm_formation.out","w",stdout);
cin>>n;
for (int i=1;i<=n;i++)
{
cin>>num[i];
sum+=num[i];
}
for (int i=1;i<=n;i++)
{
for (int j=1;j<=sum;j++)
dui[j]=0;
for (int j=1;j<=n;j++)
num1[j]=num[j];
dfs(i,1);
}
cout<<ans;
return 0;
}