#include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = int64_t; using u32 = uint32_t; using namespace std; template constexpr T INXF = ::numeric_limits::max()/32*15+208; int main() { ll n; cin >> n; map m; vector v(n); for (auto &&i : v) scanf("%d", &i), m[i]++; ll ans = 0; for (auto &&i : m) { for (auto &&j : m) { if(i == j) continue; for (auto &&k : m) { if(j == k || i == k) continue; ans += i.second*j.second*k.second; } } } cout << (ans/6)%MOD << "\n"; return 0; }