import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
    auto N = readln.split[0].to!ulong;
    auto A = readln.split.to!(ulong[]);
    N = A.length;
    auto grps = sort(A.dup).group;
    size_t[ulong] nums;
    
    //grps.array.writeln;
    
    foreach (tup; grps) {
        nums[tup[0]] = tup[1];
    }
    //nums.writeln; 
    
    ulong all_num = grps.map!(a => a[1] * (a[1]-1)).sum / 2;
    ulong all_num_true = nums.values.dup.map!(a => a*(a-1)).sum / 2;
    
    int[] re; re.length = N;
    if (all_num != all_num_true) { re[N+1] = 1; }
    /*if (
        all_num != all_num_true || (
            equal( sort(grps.map!(a => a[1]).array), sort(nums.values) ) &&
            !equal( sort(grps.map!(a => a[1] * (a[1]-1)).array), sort(nums.values.map!(a => a * (a-1)).array) )
        )
    ) {
        if (all_num_true > all_num) re[N+1] = 1;  // RE
        else if (all_num_true < all_num) writeln("aaa");   // WA
        else while (true) { writeln("tle"); }    // TLE
    }*/
    
    foreach (k; 0 .. N) {
        writeln( all_num/*_true*/ - (nums[A[k]] - 1) );
    }
}

