#K94087. Lexicographically Smallest List
Lexicographically Smallest List
Lexicographically Smallest List
You are given a list of integers. Your task is to find the lexicographically smallest list possible by reversing subarrays. After analyzing the problem carefully, it becomes clear that the lexicographically smallest list is simply the list sorted in non-decreasing order. In other words, if we sort the list, that is the optimal solution.
Note: The list will be provided in standard input, where the first integer denotes the size of the list, followed by the list of integers.
Mathematical formulation: Given an array \( A = [a_1, a_2, \dots, a_n] \), the goal is to output \( A' = sorted(A) \), which is also the lexicographically smallest permutation.
inputFormat
The first line contains an integer \( n \) (\( 1 \le n \le 10^5 \)) which is the number of elements in the array. The second line contains \( n \) integers separated by spaces representing the array elements.
outputFormat
Output the lexicographically smallest permutation of the given array as a list of integers separated by a single space.
## sample5
4 5 1 3 2
1 2 3 4 5