#P1012. [NOIP 1998 提高组] 拼数

[NOIP 1998 提高组] 拼数

Description

Given nn positive integers a1ana_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 nn, the number of integers.

The second line contains nn integers aia_i, the given integers.

Output Format

Output a positive integer, the largest possible integer.

3
13 312 343

34331213

4
7 13 4 246
7424613

Hint

Constraints: For all test points, 1n201 \leq n \leq 20, 1ai1091 \leq a_i \leq 10^9.

NOIP 1998 Senior, Problem 2.

Translated by ChatGPT 5