B. Makes And The Product

// modなし、naiveなnCr
ll nCr2(ll n, ll r){
  ll ret=1;
  rep(i,r){
    ret *= (n-i);
  }
  FOR(i,1,r+1){
    ret /= i;
  }
  return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    ll N; 
    cin>>N;

    VI A(N);
    rep(i, N) cin >> A[i];
    map<ll,ll> cnt;
    for(ll a : A)cnt[a]++;

    VI B=A;
    SORT(B);
    map<ll,ll> mp;
    rep(i,3)mp[B[i]]++;

    ll ans=1;
    for(auto pa : mp){
      ll v = pa.first;
      ll c = pa.second;
      ans *= nCr2(cnt[v], c);
    }
    p(ans);

    return 0;
}