시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 345 139 123 45.556%

문제

강민이가 초등학교 3학년일 때, 담임선생님이 이런 문제를 냈었다.

숫자 1, 2, 7, 8, 9 를 사용해서 만든 두 숫자를 더했을 때, 나올 수 있는 가장 작은 수는 무엇일까요?

강민이는 이 문제의 답이 207(78 + 129)이라고 생각했다. 그런데 선생님은 책 4페이지에 있는 비슷한 문제를 모두 풀어오라는 숙제를 내셨다. 

작년부터 프로그래밍을 시작한 강민이는 이런 숙제보다 코딩을 더 재밌어했다. 그래서 강민이는 이 숙제를 코딩으로 해결하기로 했다!

어린 강민이를 위해 코딩을 도와주자.

입력

한 줄에 하나씩 연습문제가 주어진다.

각 줄에서 첫번째로 나오는 정수 N (2 ≤ N ≤ 14) 은 연습문제에서 사용될 숫자의 갯수이다.

두번째부터 사용될 N개의 숫자가 주어진다. 0이 아닌 수가 최소 2개 이상 존재한다

마지막 줄에 0을 입력하면 프로그램이 종료된다.

출력

각 연습문제마다 정답을 출력한다.

예제 입력 1

5 1 2 7 8 9
6 3 4 2 2 2 2
9 0 1 2 3 4 0 1 2 3
0

예제 출력 1

207
447
11257
W3sicHJvYmxlbV9pZCI6Ijk0NDAiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMyMmJcdWM3OTAgXHViMzU0XHVkNTU4XHVhZTMwIiwiZGVzY3JpcHRpb24iOiI8cD5cdWFjMTVcdWJiZmNcdWM3NzRcdWFjMDAgXHVjZDA4XHViNGYxXHVkNTU5XHVhZDUwIDNcdWQ1NTlcdWIxNDRcdWM3N2MmbmJzcDtcdWI1NGMsIFx1YjJmNFx1Yzc4NFx1YzEyMFx1YzBkZFx1YjJkOFx1Yzc3NCBcdWM3NzRcdWI3ZjAgXHViYjM4XHVjODFjXHViOTdjIFx1YjBjOFx1YzVjOFx1YjJlNC48XC9wPlxyXG5cclxuPGJsb2NrcXVvdGU+PGVtPlx1YzIyYlx1Yzc5MCAxLCAyLCA3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