#K3476. Maximize Global Inversions

    ID: 25381 Type: Default 1000ms 256MiB

Maximize Global Inversions

Maximize Global Inversions

You are given an array of n integers. Your task is to rearrange the array such that the number of global inversions is maximized. A global inversion is a pair of indices \( (i,j) \) such that \( i a[j] \). It can be shown that arranging the array in descending order yields the maximum number of global inversions.

Example:

Input: 5
       1 2 3 4 5
Output: 5 4 3 2 1

inputFormat

The first line contains a single integer \( n \) denoting the number of elements in the array.

The second line contains \( n \) space-separated integers \( a_1, a_2, \ldots, a_n \).

outputFormat

Output the rearranged array (in one line) such that it is sorted in descending order, with each number separated by a single space.

## sample
5
1 2 3 4 5
5 4 3 2 1

</p>