#C8979. Sorted Squares

    ID: 53020 Type: Default 1000ms 256MiB

Sorted Squares

Sorted Squares

Given an array of integers, compute the square of each integer and then output the resulting numbers in non-decreasing order. This problem requires you to read input from standard input (stdin) and output the result to standard output (stdout). The output should be a single line containing the sorted squares, separated by a single space.

In mathematical terms, for an input array \(a_1, a_2, \dots, a_n\), you are to compute \(a_i^2\) for each valid index \(i\) and then output the sequence sorted in non-decreasing order.

inputFormat

The input is read from stdin and consists of two lines:

  • The first line contains a single integer \(n\), the number of elements in the array.
  • The second line contains \(n\) space-separated integers.

outputFormat

Print a single line to stdout with the sorted squares of the input integers. The numbers should be separated by a single space.

## sample
5
-4 -1 0 3 10
0 1 9 16 100