#include using namespace std; int memo[100000] = {0}; int sum(int N,vector vec){ if(N == 1) return memo[0] = vec[0]; else{ if(memo[N-1] != 0) return memo[N-1]; return memo[N-1] = vec[N-1] + sum(N-1,vec); } } long int T(int N,vector vec){ if(N == 2) return vec[0] * vec[1]; else{ return T(N-1,vec) + sum(N-1,vec) * vec[N-1]; } } long int S(int N,vector vec){ if(N == 3) return ((long int)vec[0] * vec[1] * vec[2]) % 1000000007; else return (S(N-1,vec) + T(N-1,vec) * vec[N-1]) % 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; }