P1012 [NOIP 1998 Senior] Concatenating Numbers

Description

Given $n$ positive integers $a_1 \dots a_n$, arrange them in a row, concatenating adjacent numbers end to end, to form the largest possible integer.

Input Format

The first line contains an integer $n$, the number of integers. The second line contains $n$ integers $a_i$, the given integers.

Output Format

Output a positive integer, the largest possible integer.

Explanation/Hint

Constraints: For all test points, $1 \leq n \leq 20$, $1 \leq a_i \leq 10^9$. NOIP 1998 Senior, Problem 2. Translated by ChatGPT 5