import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner obj = new Scanner(System.in);
        int n = obj.nextInt();
        if (n < 0) {
            System.out.println("Invalid input");
            return;
        }

        int a[] = new int[n];
        int c[] = new int[n];  // counts
        int count = 0;

        for (int i = 0; i < n; i++) {
            a[i] = obj.nextInt();
            if (a[i] <= 0) {
                System.out.println("Invalid input");
                return;
            }
            c[i] = 0;  // initialize counts
        }

        for (int i = 0; i < n; i++) {
            if (c[i] != 0) continue; // already counted → skip

            c[i] = 1; // this element itself
            for (int j = i + 1; j < n; j++) {
                if (a[i] == a[j]) {
                    c[i]++;   // increase only the first occurrence
                    c[j] = -1; // mark as "used" so it won’t be checked again
                }
            }
        }

        for (int i = 0; i < n; i++) {
            if (c[i] > 0) { // only use valid counts
                count += c[i] * c[i];
            }
        }

        System.out.println(count);
        obj.close();
    }
}
