const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    const N = lines[0] - 0
    const A = lines[1].split(' ').map(Number)

    const m = Array(N + 1).fill(0)
    for (let i = 0; i < N; i++) {
        m[A[i]]++
    }

    const f = (n, m, d = 1) => {
        let sum = n
        let add = n
        for (let i = 1; i < m; i++) {
            add += d
            sum += add
        }
        return sum
    }

    let s = 0
    for (let i = 1; i <= N; i++) {
        if (m[i] < 2) continue
        s += f(1, m[i] - 1)
    }

    for (let k = 0; k < N; k++) {
        const ans = s - (m[A[k]] - 1)
        console.log(ans)
    }

})(input)
