#include<iostream> #include<cstdio> #include<cstring> #define ll long long using namespace std; int lim[6]; ll dp[31][31][31][31][31]; int main(){ int n; while(scanf("%d",&n)==1){ memset(lim,0,sizeof lim); memset(dp,0,sizeof dp); for(int i=1;i<=n;i++) scanf("%d",&lim[i]); dp[0][0][0][0][0]=1; for(int i=0;i<=lim[1];i++){ for(int j=0;j<=lim[2];j++){ if(j>i)continue;//j>i这种状态不可能成立 for(int k=0;k<=lim[3];k++){ if(k>j || k>i)continue; for(int l=0;l<=lim[4];l++){ if(l>k||l>j||l>i)continue; for(int m=0;m<=lim[5];m++){ if(m>l || m>k || m>j || m>i)continue; if(i+1<=lim[1]) dp[i+1][j][k][l][m]+=dp[i][j][k][l][m]; if(j+1<=lim[2]) dp[i][j+1][k][l][m]+=dp[i][j][k][l][m]; if(k+1<=lim[3]) dp[i][j][k+1][l][m]+=dp[i][j][k][l][m]; if(l+1<=lim[4]) dp[i][j][k][l+1][m]+=dp[i][j][k][l][m]; if(m+1<=lim[5]) dp[i][j][k][l][m+1]+=dp[i][j][k][l][m]; } } } } } printf("%lld ",dp[lim[1]][lim[2]][lim[3]][lim[4]][lim[5]]); } }