#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<iostream>
#include<string>
#include<cmath>
#define MAXL 5010
#define N 100010
#define FOR(i,a,b) for(i=(a);i<=(b);i++)
#define ROF(i,a,b) for(i=(a);i>=(b);i--)
typedef long long LL;
using namespace std;
struct num{int a[MAXL+100];void clear(){memset(a,0,sizeof(a));}}tmp,ans,m0;
int c1[N],c2[N],b[N],prime[N],len=0,n,d[N];
num operator*(num A,num B)
{
  num C;int x,i,j;C.clear();
  FOR(i,1,A.a[0])
  {
    x=0;
    FOR(j,1,B.a[0])
    {
      C.a[i+j-1]+=x+A.a[i]*B.a[j];
      x=C.a[i+j-1]/10;
      C.a[i+j-1]%=10;
    }
    C.a[i+B.a[0]]=x;
  }
  ROF(i,A.a[0]+B.a[0]+1,1)
   if (C.a[i]) {C.a[0]=i;break;}
  if (!C.a[0]) C.a[0]=1;
  return C;
}
num LLtonum(LL x)
{
  num C;C.clear();
  if (x==0) {C.a[0]=1;return C;}
  while (x)
  {
    C.a[0]++;
    C.a[C.a[0]]=x%10;
    x/=10;
  }
  return C;
}
void initprime(int n)
{
  memset(b,0,sizeof(b));
  int i,j;
  FOR(i,2,n)
  {
    if (!b[i]) prime[++len]=i;
    FOR(j,1,len)
    {
      if (i*prime[j]>n) break;
      b[i*prime[j]]=1;
      if (i%prime[j]==0) break;
    }
  }
}
void add(int n,int wq)
{
  int i;
  FOR(i,1,len) 
  {
    int tp=prime[i];
    while (n>=tp)
    {
      if (wq==0) c1[i]+=n/tp;else c2[i]+=n/tp;
      tp*=prime[i];
    }
  }
}
num powp(num x,int P)
{
  num e=x,res=m0;
  for(;P;P>>=1)
  {
    if (P&1) res=res*e;
    e=e*e;
  }
  return res;
}
int main()
{
  scanf("%d",&n);int m=0,tot=0,i,j;
  FOR(i,1,n)
  {
    scanf("%d",&d[i]);
    if (d[i]==-1) ++m;else tot+=d[i]-1;
  }
  initprime(2010);
  int cc1=n-2-tot,cur=m;
  FOR(i,1,len)
  {
    if (cur==1) break;
    while (cur%prime[i]==0) c1[i]++,cur/=prime[i];
  }
  FOR(i,1,len) c1[i]*=cc1;
  add(n-2,0);add(n-2-tot,1);
  FOR(i,1,n)
   if (d[i]!=-1) add(d[i]-1,1);
  FOR(i,1,len) c1[i]-=c2[i];
  m0.clear();m0.a[0]=m0.a[1]=1;
  ans=m0;
  FOR(i,1,len)
  {
    tmp=LLtonum(prime[i]);
    tmp=powp(tmp,c1[i]);
    ans=ans*tmp;
  }
  ROF(i,ans.a[0],1) printf("%d",ans.a[i]);
  printf("\n");
}