You need to implement a function named construct_permuted_array that takes an integer n and a list of integers a of length n. The function should return a new list that is a permutation of a based on a specific transformation. The transformation involves creating a shifted version of the sorted list of a, where the last element of the sorted list becomes the first element, and all other elements are shifted one position to the right.
Input Requirements
The function should accept:
An integer n (1 ≤ n ≤ 1000), representing the number of elements in the list.
A list a containing n integers (0 ≤ a[i] ≤ 10^9 for each i in range(n)).
Output Requirements
The function should return a list b of n integers, which is the permuted version of a after applying the specified transformation.
File Structure
The solution must be implemented in a file called /app/solution.py.
Example
python
# Input
n = 5
a = [4, 3, 2, 1, 5]
# Output
b = [5, 4, 3, 2, 1]
In the example above:
The sorted version of a is [1, 2, 3, 4, 5].
The shifted sorted version is [5, 1, 2, 3, 4].
The output list b is created by mapping each element of a to the corresponding index in the shifted sorted list.