#include<bits/stdc++.h>
using namespace std;
int chap(int k, int n){
if(k == 0 || k == n) return 1;
else if(k == 1) return n;
return chap(k - 1, n - 1) + chap(k, n - 1);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n; cin >> n;
int a[n + 1];
map <int, int> mp;
for(int i = 0 ; i < n ; ++i){
cin >> a[i];
++mp[a[i]];
}
int ans = 0;
for(auto it : mp){
if(it.second == 2) ++ans;
else if(it.second > 2) ans += chap(2, it.second);
}
cout << ans;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IGNoYXAoaW50IGssIGludCBuKXsKCWlmKGsgPT0gMCB8fCBrID09IG4pIHJldHVybiAxOwoJZWxzZSBpZihrID09IDEpIHJldHVybiBuOwoJcmV0dXJuIGNoYXAoayAtIDEsIG4gLSAxKSArIGNoYXAoaywgbiAtIDEpOwp9CmludCBtYWluKCkKewoJaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CgljaW4udGllKE5VTEwpOwoJaW50IG47IGNpbiA+PiBuOwoJaW50IGFbbiArIDFdOwoJbWFwIDxpbnQsIGludD4gbXA7Cglmb3IoaW50IGkgPSAwIDsgaSA8IG4gOyArK2kpewoJCWNpbiA+PiBhW2ldOwoJCSsrbXBbYVtpXV07Cgl9CglpbnQgYW5zID0gMDsKCWZvcihhdXRvIGl0IDogbXApewoJCWlmKGl0LnNlY29uZCA9PSAyKSArK2FuczsKCQllbHNlIGlmKGl0LnNlY29uZCA+IDIpIGFucyArPSBjaGFwKDIsIGl0LnNlY29uZCk7Cgl9Cgljb3V0IDw8IGFuczsKCXJldHVybiAwOwp9