#include using namespace std; int memo[100000] = {0}; int sum(int N,vector vec){ if(N == 1) return memo[1] = vec[1]; else{ if(memo[N] != 0) return memo[N]; return memo[N] = vec[N] + sum(N-1,vec); } } long int T(int N,vector vec){ if(N == 2) return vec[1] * vec[2]; else{ return T(N-1,vec) + sum(N-1,vec) * vec[N]; } } long int S(int N,vector vec){ if(N == 3) return vec[1] * vec[2] * vec[3]; else return (S(N-1,vec) + T(N-1,vec) * vec[N]) % 1000000007; } int main(){ int N; cin >> N; vector L(N,0); map m; for(int i=0;i> L[i]; m[L[i]]++; } vector vec = {}; for(auto i : m){ vec.push_back(i.second); } cout << S(vec.size(),vec) << endl; return 0; }