#!/usr/bin/env python3 # 想定解 import collections import math N = int(input()) A = list(map(int, input().split())) ret = math.factorial(N) for val in collections.Counter(A).values(): ret //= math.factorial(val) print(ret)