local n = io.read("*n")
local a = {}
local pseudo_set = {}
for i = 1, n do
    a[i] = io.read("*n")
    if pseudo_set[a[i]] then
        table.insert(pseudo_set[a[i]], i)
    else
        pseudo_set[a[i]] = {i}
    end
end

local outs = {}
local subtotals = {}
local only_one_out = nil
local answers = {}
local function combination(num, indexes_len)
    if subtotals[num] then
        return subtotals[num]
    end
    if indexes_len >= 2 then
        subtotals[num] = indexes_len * (indexes_len - 1) / 2
    else
        subtotals[num] = 0
    end
    return subtotals[num]
end
local function sumCom(arg_num)
    local sum = 0
    for num, indexes in pairs(pseudo_set) do
        if num == arg_num then
            local indexes_len = #indexes - 1
            if indexes_len >= 2 then
                sum = sum + indexes_len * (indexes_len - 1) / 2
            end
        else
            sum = sum + combination(num, #indexes)
        end
    end
    return sum
end

for num, indexes in pairs(pseudo_set) do
    if #indexes == 1 then
        if only_one_out == nil then
            only_one_out = sumCom(nil)
        end
        outs[indexes[1]] = only_one_out
    else
        if answers[num] == nil then
            answers[num] = sumCom(num)
        end
        for key, a_position in pairs(indexes) do
            outs[a_position] = answers[num]
        end
    end
end
print(table.concat(outs, "\n"))