use std::io::Read; fn fact(n: u128) -> u128 { if n == 0 { 1 } else { n * fact(n - 1) } } fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let a: Vec = itr.map(|e| e.parse::().unwrap() - 1).collect(); let mut c = vec![0usize; n]; for i in 0..n { c[a[i]] += 1; } let mut ans = fact(n as u128); for i in c{ if i > 0 { ans /= fact(i as u128) } } println!("{}", ans); }