Given an array of integers. Sort the array by non-increasing sum of digits of each number. If the sum of the digits of two numbers is equal, the numbers must follow in descending order.
Input
The program receives as input in the first line a natural number
n
- the size of the array. The second line contains
n
integers
ai
- array elements (
1 <= n <= 103,
1  ;<= ai <= 104
).
Imprint
Output the resulting array.
Examples
# |
Input |
Output |
1 |
4
1 43 12 10
| 43 12 10 1 |
Запрещенные операторы:sort