#include #include using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<(n);i++) int n, a[100010]; const int mod = 1e9 + 7; ll conbination(int x){ ll ret = x * (x - 1) * (x - 2) / 6; return ret; } int main(void){ cin >> n; rep(i, n) cin >> a[i]; int cnt[110]; rep(i, 110) cnt[i] = 0; rep(i, n){ cnt[a[i]]++; } int c = 0, k = 1; rep(i, 101){ if(cnt[i] >= 1){ k *= cnt[i]; c++; } } // printf("%d %d\n", c, k); ll ans = conbination(c) * k % mod; printf("%lld\n", ans); return 0; }