A Problem for Alf
InterviewTime limit2sMemory limit1024 MB
Arrange the given non-negative integers in an order so that concatenating them produces the largest possible number.
Problem
Willy Tanner gave Alf an interesting problem to keep him busy.
Alf has non-negative integers. Any number can be appended to the end of another number to form a new number. For example, from and you can get either or . The task is to join all the numbers into one so that the result is as large as possible. If Alf has the two numbers and , the answer is .
Willy gave Alf a very large number of integers. The TV will not watch itself, so Alf asks you to write a program that solves the problem.
Input
The first line contains (), the number of integers Alf was given. The second line contains integers (), separated by spaces.
Output
Print the integers from the input, separated by spaces, in an order such that concatenating them in sequence gives the largest possible number.