/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>
typedef long long LL;
using namespace std;
int num[315][1005];
int ans[1005];
int q[15];
int n, a[30];
void init(){
num[1][0] = 1;
num[1][1] = 1;
int len = 1;
for (int i = 2; i <= 312; i++){
for (int j = 1; j <= len; j++){
num[i][j] += num[i - 1][j] * i;
if(num[i][j] >= 10){
int t = num[i][j] / 10;
num[i][j] %= 10;
num[i][j + 1] += t;
}
}
while(num[i][len + 1]){
if(num[i][len + 1] >= 10){
num[i][len + 2] = num[i][len + 1] /10;
num[i][len + 1] %= 10;
}
len++;
}
num[i][0] = len;
// for (int j = num[i][0]; j >= 1; j--){
// printf("%d", num[i][j]);
// }
// printf("\n");
}
q[1] = 1;
for (int i = 2; i <= 12; i++){
q[i] = q[i - 1] * i;
}
}
void solve(int x){
LL temp = 0;
for (int i = ans[0]; i >= 1; i--){
temp = temp * 10 + ans[i];
ans[i] = temp / x;
temp %= x;
}
int len = ans[0];
while(!ans[len] && len > 1){
len--;
}
ans[0] = len;
}
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
init();
while(scanf("%d", &n) == 1){
if(n == 0) break;
int sum = 0;
for (int i = 1; i <= n; i++){
scanf("%d", &a[i]);
sum += a[i];
}
memcpy(ans, num[sum], sizeof(num[sum]));
for (int i = 1; i <= n; i++){
solve(q[a[i]]);
}
for (int i = ans[0]; i >= 1; i--){
printf("%d", ans[i]);
}
printf("\n");
}
return 0;
}
/**/