LogiQuest

278. Minimum Sum from Digits

EasyGreedy

Use every digit exactly once to form two numbers whose sum is as small as possible. Print the sum.

Input format

Line 1: n Line 2: n digits (0–9)

Output format

The minimum sum.

Example 1

Input

6
6 8 4 5 2 3

Output

604

Example 2

Input

5
5 3 0 7 4

Output

82

Constraints

2 ≤ n ≤ 30

Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.

Loading the MyLoginn IDE…