#pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma") #include //#include //using namespace atcoder; //#include //#include //#include //#include #define fi first #define se second using namespace std; //using namespace __gnu_pbds; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef pair pii; typedef pair pll; typedef pair pdb; typedef tuple tii; typedef tuple tdb; typedef tuple tll; typedef tuple ti4; typedef tuple tl4; typedef tuple td4; //typedef tree,rb_tree_tag,tree_order_statistics_node_update> oset; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //shuffle(a+1,a+1+n,rng) uniform_int_distribution<> gen(1,100); //gen(rng) ll modinv(ll a,ll m){ if(m==1) return 0; a%=m; if(a<0) a+=m; if(a==1) return 1; return m-modinv(m,a)*m/a; } template struct modnum{ private: int v; public: static const int MOD = MOD_; modnum() : v(0) {} modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; } explicit operator int () const { return v; } friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; } friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; } friend bool operator < (const modnum& a, const modnum& b) { return a.v < b.v; } friend bool operator <= (const modnum& a, const modnum& b) { return a.v <= b.v; } friend bool operator > (const modnum& a, const modnum& b) { return a.v > b.v; } friend bool operator >= (const modnum& a, const modnum& b) { return a.v >= b.v; } modnum operator ~ () const { modnum res; res.v = modinv(v, MOD); return res; } modnum& operator += (const modnum& o) { v += o.v; if (v >= MOD) v -= MOD; return *this; } modnum& operator -= (const modnum& o) { v -= o.v; if (v < 0) v += MOD; return *this; } modnum& operator *= (const modnum& o) { v = int(ll(v) * ll(o.v) % MOD); return *this; } modnum& operator /= (const modnum& o) { return *this *= (~o); } modnum operator-() const { return modnum(-v); } modnum& operator++() { return *this += 1; } modnum operator++(int){ modnum tmp=*this; ++*this; return tmp; } modnum& operator--() { return *this -= 1; } modnum operator--(int){ modnum tmp=*this; --*this; return tmp; } friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; } friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; } friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; } friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; } friend modnum pow(modnum a, ll p) { modnum ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a; return ans; } friend ostream& operator<<(std::ostream& os, const modnum& o) { os << o.v; return os; } friend istream& operator>>(std::istream& is, modnum& o) { is >> o.v; return is; } }; using mi=modnum<1000000007>; const int N=25,M=(1<<21),Q=1e6+5; const ll mod=1000000007,inf=1e18; int n,a[N]; ll fact[N],res=1; int main(){ ios::sync_with_stdio(false); cin.tie(0); cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; sort(a+1,a+1+n); fact[1]=1; for(int i=2;i<=n;i++) fact[i]=fact[i-1]*i; for(int i=1;i<=n;i++){ int j=i; while(j+1<=n&&a[i]==a[j+1]) j++; res*=fact[j-i+1]; i=j; } cout<