import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    auto I = iota(N).array;
    zip(A, I).sort();
    auto tmp = new long[](2 * 10 ^^ 5 + 1);
    long i;
    long sum;
    while (i < N)
    {
        long j = i;
        while (A[i] == A[j])
            j++;
        long x = j - i;
        tmp[A[i]] = x;
        long y = x * (x - 1) / 2;
        sum += y;
        i = j;
    }
    auto ans = new long[](N);
    foreach (j; 0 .. N)
    {
        ans[I[j]] = sum - (tmp[A[j]] * (tmp[A[j]] - 1) / 2) + ((tmp[A[j]] - 1) * (tmp[A[j]] - 2) / 2);
    }
    foreach (a; ans)
        writeln(a);
}
