#include using namespace std; #define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++) #define REP(i,e) FOR(i,0,e) #define RFOR(i,e,s) for(int (i)=(e)-1;(i)>=(int)(s);(i)--) #define RREP(i,e) RFOR(i,0,e) #define all(o) (o).begin(), (o).end() #define psb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) typedef long long ll; typedef pair PII; typedef priority_queue PQI; typedef priority_queue PQII; const double EPS = 1e-10; const int N = 1e5; const ll mod = 1e9+7; int n; int a[N]; int main() { scanf("%d ", &n); vector b(n); REP(i,n) { scanf("%d ", a+i); b[i] = a[i]; } sort(all(b)); b.erase(unique(all(b)), b.end()); int m = (int)b.size(); map idx; REP(i,m) idx[b[i]] = i; fill(all(b), 0); REP(i,n) b[idx[a[i]]]++; ll res = 0; REP(i,m) FOR(j,i+1,m) FOR(k,j+1,m) { ll tmp = (ll)b[i]; tmp = (tmp*b[j]) % mod; tmp = (tmp*b[k]) % mod; res = (res + tmp) % mod; } printf("%lld\n", res); return 0; }