#C13564. Sorted Squares of an Array

    ID: 43116 Type: Default 1000ms 256MiB

Sorted Squares of an Array

Sorted Squares of an Array

Given an array of integers, compute a new array containing the squares of each element, then sort the array in non-decreasing order.

The input consists of an integer n specifying the number of elements, followed by n space-separated integers. Your task is to output the sorted list of squared values as space-separated integers on a single line.

Formally, for an input sequence \(a_1, a_2, \ldots, a_n\), output the sequence \(a_1^2, a_2^2, \ldots, a_n^2\) sorted in non-decreasing order.

inputFormat

The first line of input contains a single integer n, the number of elements in the array.

The second line contains n space-separated integers which represent the elements of the array.

outputFormat

Output a single line containing the sorted squares of the input integers, separated by a space.

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