#C11472. Largest Number Concatenation

    ID: 40792 Type: Default 1000ms 256MiB

Largest Number Concatenation

Largest Number Concatenation

You are given a list of non-negative integers. Your task is to arrange them such that they form the largest possible number when concatenated together.

For example, given the list [3, 30, 34, 5, 9], the largest formed number is 9534330. Note that the result is a string because the number can be very large and may exceed integer limits.

When all numbers are zeros, the output should be 0.

The result should be printed to stdout and the input is read from stdin.

inputFormat

The input begins with an integer n denoting the number of elements in the list.

The next line contains n space-separated non-negative integers.

For example:

5
3 30 34 5 9

outputFormat

Output a single line containing the largest number (as a string) that can be formed by concatenating the given integers.

For the sample input, the output should be:

9534330
## sample
5
3 30 34 5 9
9534330

</p>