#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;
int ar[n+5];
for (int i = 1; i <= n; i++){
cin >> ar[i];
}
map<int,int> freq;
for (int i = 1; i <= n; i++){
freq[ar[i]] += 1;
}
//use a long long because it can store a bigger number
long long ans = 0, tot = n;
/*
n = 5
1 1 2 2 3
{{1: 2}, {2: 2}, {3: 1}}
it = {3: 1}
it.first = 3
it.second = 1
*/
for (auto it: freq){
int val = it.second;
ans += val*(tot-val);
tot -= val;
}
cout << ans << endl;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCl7CiAgICBpbnQgbjsgY2luID4+IG47CiAgICBpbnQgYXJbbis1XTsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKyl7CiAgICAgICAgY2luID4+IGFyW2ldOwogICAgfQoKICAgIG1hcDxpbnQsaW50PiBmcmVxOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKXsKICAgICAgICBmcmVxW2FyW2ldXSArPSAxOwogICAgfQoKICAgIC8vdXNlIGEgbG9uZyBsb25nIGJlY2F1c2UgaXQgY2FuIHN0b3JlIGEgYmlnZ2VyIG51bWJlcgogICAgbG9uZyBsb25nIGFucyA9IDAsIHRvdCA9IG47CgogICAgLyoKICAgIG4gPSA1CiAgICAxIDEgMiAyIDMKCiAgICB7ezE6IDJ9LCB7MjogMn0sIHszOiAxfX0KCiAgICBpdCA9IHszOiAxfQogICAgaXQuZmlyc3QgPSAzCiAgICBpdC5zZWNvbmQgPSAxCiAgICAqLwogICAgZm9yIChhdXRvIGl0OiBmcmVxKXsKICAgICAgICBpbnQgdmFsID0gaXQuc2Vjb25kOwogICAgICAgIGFucyArPSB2YWwqKHRvdC12YWwpOwogICAgICAgIHRvdCAtPSB2YWw7CiAgICB9CgogICAgY291dCA8PCBhbnMgPDwgZW5kbDsKfQ==