#include #include #include #include #include #include #include #include #include using namespace std; #define FOR(x,y) for(int x = 0;x < y;x++) #define LLI long long int template class UF { public: vector par,rank,cnt; UF() {par=rank=vector(um,0); cnt=vector(um,1); for(int i=0;irank[y]) return par[x]=y; rank[x]+=rank[x]==rank[y]; return par[y]=x; } }; int main() { int n; cin >> n; map data; vector buffer; FOR(i, n) { int value; cin >> value; if(data.find(value) == data.end()) { data[value] = 1; buffer.push_back(value); } else { data[value]++; } } const LLI mod = 1000000007; LLI count = 0; do { count++; count %= mod; }while(next_permutation(buffer.begin(), buffer.end())); count /= 6; for(auto iterator = data.begin(); iterator != data.end();iterator++) { count *= iterator->second; count %= mod; } cout << count << endl; return 0; }