Interesting Sorting
Medium
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
You are given an array of N natural numbers. Your task is to sort this array in ascending order based on the sum of the digits of each number. If two numbers have the same digit sum, sort them in descending order by their value.
Input
The first line contains the integer n ( ≤ ≤ ), representing the number of natural numbers. The following n lines each contain one natural number, with each number not exceeding .
Output
Print the sequence of numbers sorted according to the specified conditions.
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 15%