#K53517. Squared Sorted Array

    ID: 29549 Type: Default 1000ms 256MiB

Squared Sorted Array

Squared Sorted Array

You are given a list of ( n ) integers. Your task is to compute the square of each integer using the formula ( x^2 ) and then output the squared values in non-decreasing (ascending) order.

The input is provided via standard input, and the output should be printed to standard output. This problem tests your ability to manipulate arrays and perform sorting operations efficiently.

inputFormat

The input is given through standard input and consists of two lines:

  1. The first line contains a single integer ( n ), representing the number of elements in the list.
  2. The second line contains ( n ) space-separated integers.

outputFormat

Print a single line to standard output containing the squared values of the input integers, sorted in non-decreasing order. The values should be separated by a single space.## sample

4
-1 2 3 -4
1 4 9 16