def main():

    dates = int(eval(input()))

    numbers = list(map(int, input().split()))

    count = {i: 0 for i in range(1, dates + 1)}

    for n in numbers:

        count[n] += 1

    answer = 0

    for c in list(count.values()):

        answer += c * (c - 1) // 2

    for n in numbers:

        print((answer - count[n] + 1))





if __name__ == '__main__':

    main()



def main():

    n = int(eval(input()))

    a = [int(x) for x in input().split()]

    count = {}

    for aa in a:

        if aa in count:

            count[aa] += 1

        else:

            count[aa] = 1

    all_way = 0

    for c in list(count.values()):

        all_way += c * (c - 1) // 2

    for i in range(n):

        if a[i] in count:

            print((all_way - count[a[i]] + 1))

        else:

            print(all_way)





if __name__ == '__main__':

    main()



def main():
    dates = int(eval(input()))
    numbers = list(map(int, input().split()))
    count = {i: 0 for i in range(1, dates + 1)}
    for n in numbers:
        count[n] += 1
    answer = 0
    for c in list(count.values()):
        answer += c * (c - 1) // 2
    for n in numbers:
        print((answer - count[n] + 1))


if __name__ == "__main__":
    main()

def main():
    n = int(eval(input()))
    a = [int(x) for x in input().split()]
    count = {}
    for aa in a:
        if aa in count:
            count[aa] += 1
        else:
            count[aa] = 1
    all_way = 0
    for c in list(count.values()):
        all_way += c * (c - 1) // 2
    for i in range(n):
        if a[i] in count:
            print((all_way - count[a[i]] + 1))
        else:
            print(all_way)


if __name__ == "__main__":
    main()

-    dates = int(eval(input())) -    numbers = list(map(int, input().split())) -    count = {i: 0 for i in range(1, dates + 1)} -    for n in numbers: -        count[n] += 1 -    answer = 0 +    n = int(eval(input())) +    a = [int(x) for x in input().split()] +    count = {} +    for aa in a: +        if aa in count: +            count[aa] += 1 +        else: +            count[aa] = 1 +    all_way = 0 -        answer += c * (c - 1) // 2 -    for n in numbers: -        print((answer - count[n] + 1)) +        all_way += c * (c - 1) // 2 +    for i in range(n): +        if a[i] in count: +            print((all_way - count[a[i]] + 1)) +        else: +            print(all_way)