#include<bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
#define PI acos(-1)
#define deb(x) cout<<#x<<" "<<x<<endl;
//ALWAYS USE ll DATA TYPE FOR INTEGER(FASTER THAN INTEGER AS WELL AS SOMETIMES WITHOUT USE LONG UR ANSWER WILL NOT ACCEPTED) && DOUBLE FOR DECIMAL VALUE
template<typename T> // for removing front element from the vector
void pop_front(std::vector<T> &v)
{
    if (v.size() > 0) {
        v.erase(v.begin());
    }
}
template<typename R> // for removing back element from the vector or can directly
void pop_back(std::vector<R> &v) // use vec.pop_back() function...
{
    if (v.size() > 0) {
        v.erase(v.begin()+v.size()-1);
    }
}

bool isprime(ll n)  //IN  O(sqrt(n))
{
    if(n<=1) return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;

    return true;
}

vector<ll> factors(ll n){    //IN  O(sqrt(n))

    vll v;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            v.pb(i);
            if((n/i)!=i)
            v.pb(n/i);
        }
    }
    return v;
}

ll power(ll a, ll n)  // using Binary Exponential in TC O(logn)
{                     // Self Written By </ME> :)
    ll res=1;
    while(1)
    {
        if(n%2){
            res=res*a; n--;
        }
        if(n==0) break;
        a=a*a; n/=2;
    }
    return res;
}

ll ts(ll arr[],int l,int r,int x) // ternary search to find x in sorted array arr
{
    
    while(l<=r)
    {
        ll mid1= l+(r-l)/3;
        ll mid2= r -(r-l)/3;
        if(arr[mid1]==x || arr[mid2]==x)
            return 1;
        if(x<arr[mid1])
            r=mid1-1;
        else if(x>arr[mid2])
            l=mid2+1;
        else
        {
            l=mid1+1;
            r=mid2-1;
        }
    }

    return -1;
}

ll f(ll a)
{
    if(a%2==0)
    {
        return ((a/2)*(a-1));
    }
    else
        return (((a-1)/2)*a);
}



ll check(unordered_map<ll,ll>s,ll a)
{
    for(auto x: s)
    {
        if(x.second==a)
            return x.first;
    }

    return -1;
}


ll res[200005];

int main() {
    auto start = chrono::high_resolution_clock::now();
    fio;
    ll T=1;
    //cin>>T;
    while(T--)
    {
      ll n; cin>>n;
      ll arr[n]; rep(i,0,n) cin>>arr[i];
      memset(res,-1,sizeof(res));
      unordered_map<ll,ll>mp;
      for(int i=0;i<n;i++)
        mp[arr[i]]++;

    unordered_map<ll,ll>s;
    

    for(ll k=0;k<n;k++)
    {
         ll a=mp[arr[k]];
         ll b=check(s,a);
         if(b==-1) //Not  found
         {

            if(res[arr[k]]==-1)
        {
            ll ans=0;
            mp[arr[k]]--;
        for(auto x: mp)
        {
            ll v=x.second;
            ans+=f(v);
        }

        mp[arr[k]]++;
        res[arr[k]]=ans;

        //cout<<"aya tha bhai mai"<<"\n";
        s.insert({arr[k],mp[arr[k]]});

        }


         }
         else   //found
         {

            arr[k]=b;


         }
    }

    for(int i=0;i<n;i++)
        cout<<res[arr[i]]<<"\n";    


    //for(int i=0;i<n;i++)
    //    cout<<arr[i]<<" ";


    }
    
    auto finish = chrono::high_resolution_clock::now();
    cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
    return 0;
}





Measured memory_bytes: 10696