#C12255. Square and Sort in Descending Order
Square and Sort in Descending Order
Square and Sort in Descending Order
Given a list of integers, your task is to compute the square of each element, i.e. \(x^2\), and then output the squared values sorted in descending order.
The input begins with an integer \(n\) (where \(n \ge 0\)) representing the number of elements, followed by a line of \(n\) space-separated values. If any element is not a valid integer, output the exact message: "All elements in the input list must be integers."
inputFormat
The first line contains an integer \(n\), indicating the number of elements. The second line contains \(n\) space-separated values. All values must be valid integers.
outputFormat
If all inputs are valid integers, output a single line containing the squares of these integers (i.e. each integer \(x\) is replaced by \(x^2\)), sorted in descending order and separated by spaces. If any value is not an integer, output "All elements in the input list must be integers."
## sample5
1 2 3 4 5
25 16 9 4 1