# D - Banned K

from collections import Counter





def main():

    N, *A = list(map(int, open(0).read().split()))

    counter = Counter(A)

    patterns, less_patterns = {}, {}

    for k, v in list(counter.items()):

        patterns[k] = max(0, v * (v - 1) // 2)

        less_patterns[k] = max(0, (v - 1) * (v - 2) // 2)

    total = sum(patterns.values())

    ans = [total - patterns[a] + less_patterns[a] for a in A]

    print(("\n".join(map(str, ans))))





if __name__ == "__main__":

    main()

# D - Banned K

from collections import Counter





def main():

    N, *A = list(map(int, open(0).read().split()))

    counter = Counter(A)

    total = 0

    dif = {}

    for k, v in list(counter.items()):

        total += max(0, v * (v - 1) // 2)

        dif[k] = max(0, v - 1)

    ans = [total - dif[a] for a in A]

    print(("\n".join(map(str, ans))))





if __name__ == "__main__":

    main()

# D - Banned K
from collections import Counter


def main():
    N, *A = list(map(int, open(0).read().split()))
    counter = Counter(A)
    patterns, less_patterns = {}, {}
    for k, v in list(counter.items()):
        patterns[k] = max(0, v * (v - 1) // 2)
        less_patterns[k] = max(0, (v - 1) * (v - 2) // 2)
    total = sum(patterns.values())
    ans = [total - patterns[a] + less_patterns[a] for a in A]
    print(("\n".join(map(str, ans))))


if __name__ == "__main__":
    main()

# D - Banned K
from collections import Counter


def main():
    N, *A = list(map(int, open(0).read().split()))
    counter = Counter(A)
    total = 0
    dif = {}
    for k, v in list(counter.items()):
        total += max(0, v * (v - 1) // 2)
        dif[k] = max(0, v - 1)
    ans = [total - dif[a] for a in A]
    print(("\n".join(map(str, ans))))


if __name__ == "__main__":
    main()

-    patterns, less_patterns = {}, {} +    total = 0 +    dif = {} -        patterns[k] = max(0, v * (v - 1) // 2) -        less_patterns[k] = max(0, (v - 1) * (v - 2) // 2) -    total = sum(patterns.values()) -    ans = [total - patterns[a] + less_patterns[a] for a in A] +        total += max(0, v * (v - 1) // 2) +        dif[k] = max(0, v - 1) +    ans = [total - dif[a] for a in A]