from collections import Counter from math import factorial def main(): N = int(input()) A = list(map(int, input().split())) counter_A = Counter(A) all_pattern_nums = factorial(N) for appear_num in counter_A.values(): all_pattern_nums //= factorial(appear_num) print(all_pattern_nums) if __name__ == "__main__": main()