#C14127. Square and Deduplicate

    ID: 43742 Type: Default 1000ms 256MiB

Square and Deduplicate

Square and Deduplicate

This problem requires you to take a list of integers, compute the square of each integer, remove any duplicate squared values, and output the unique squared numbers in sorted order. In other words, given a list of integers A = [a1, a2, ..., an], you need to produce a list B such that \(B = sorted(\{a_i^2 : 1 \leq i \leq n\})\). Make sure your solution handles negative numbers correctly, since \( (-a)^2 = a^2 \).

inputFormat

The input consists of two lines. The first line contains a single integer n denoting the number of elements in the list. The second line contains n space-separated integers.

outputFormat

Output the unique squared integers in ascending order, separated by a single space. If the list is empty (i.e. n = 0), output nothing.

## sample
4
1 2 3 2
1 4 9