#include #include #include using namespace std; const int MOD = (int)1e9 + 7; int main() { int n; cin >> n; vector a(n); for (int &ai: a) cin >> ai; vector cnt(101); for (int ai: a) cnt[ai]++; long long acc1 = 0, acc2 = 0, acc3 = 0; for (auto ci: cnt) { acc1 += ci; acc2 += ci * ci; acc3 += ci * ci * ci; } long long ans = (acc1 * (acc1 * acc1 - acc2 * 3) + acc3 * 2) / 6; cout << ans % MOD << endl; return 0; }