#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define ch(a) (int(a-'a')+1)
#define mm(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define inf  0x7FFFFFFF
typedef long long ll;
const int Maxx=3*1e5+10;
ll a[Maxx];
int main()
{
    int n;
    IOS;
    cin>>n;
    rep(i,1,n) cin>>a[i];
    ll ans=1LL*(n-1)*n/2;
    sort(a+1,a+n+1);
    ll tmp=1;
    for(int i=1;i<=(n-1);i++)
    {
        if(a[i]==a[i+1])
        {
            ++tmp;
        }
        else 
        {
            ans-=1LL*(tmp-1)*tmp/2;tmp=1;
        }
    }
    ans-=1LL*(tmp-1)*tmp/2;
    cout<<ans<<endl;
    return 0;
}

#pragma region Macros
#include <bits/stdc++.h>
#if defined(LOCAL) || defined(ONLINE_JUDGE) || defined(_DEBUG)
#include <atcoder/all>
#endif
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>using vec = vector<T>;
template<class T, class U>using umap = unordered_map<T, U>;
using ll = long long;
using P = pair<ll, ll>;
using vl = vec<ll>;
#define fi first
#define se second
#define el endl
constexpr ll INF = numeric_limits<ll>::max()/2-1;
#pragma endregion

#pragma region IOMacros
template<class T>
istream &operator>>(istream &stream, vec<T>& o){REP(i, o.size())stream >> o[i];return stream;}
template<class T>
ostream &operator<<(ostream &stream, vec<T>& objs){REP(i, objs.size())stream << objs[i] << " ";stream << el;return stream;}

#define I(T, ...) ;T __VA_ARGS__;__i(__VA_ARGS__);
void __i() {}
template<class T, class... Ts> void __i(T&& o, Ts&&... args){cin >> o;__i(forward<Ts>(args)...);}

void O() {cout << el;}
template<class T, class... Ts> void O(T&& o, Ts&&... args){cout << o << " ";O(forward<Ts>(args)...);}
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

// 約数列挙
//O(√N)
vector<ll> enumDivisors(ll N) {
    vector<ll> res1, res2;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res1.push_back(i);
            if (N/i != i) res2.push_back(N/i);
        }
    }
    res1.reserve(res1.size()+res2.size());
    copy(res2.rbegin(), res2.rend(), back_inserter(res1));
    return res1;
}

void Main(){
    I(ll, N);
    auto div = enumDivisors(N);
    EACH(v, div){
        cout << v << el;
    }
}
