#include<bits/stdc++.h>
using namespace std;

long fct(int N){
  long res=1;
  while(N){
    res*=N;
    N--;
  }
  return res;
}

int main(){
  int N;
  cin>>N;
  vector<long> cnt(N);
  for(int i=0;i<N;++i){
    int a;
    cin>>a;
    cnt[a-1]++;
  }
  long ans=fct(N);
  for(int i=0;i<N;++i){
    ans/=fct(cnt[i]);
  }
  cout<<ans<<endl;
}