시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB1471098171.053%

문제

Space Ranger is caught at an alien spaceship. He is surrounded by enemies. To break free he needs to destroy all enemies in some particular order.

There are n enemies around Space Ranger, the i-th of them has power fi. To break free Space Ranger needs to destroy all enemies in such order, that the power of the last destroyed enemy is equal to the sum of powers of all other enemies.

Space Ranger is short of time, so he has failed to find the required order. Help him! Find the way to destroy all enemies and break free.

입력

The first line of input contains n — the number of enemies (2 ≤ n ≤ 105).

The second line contains n integers fi — powers of the enemies (-109 ≤ fi ≤ 109).

출력

Output values fi in order in which the enemies must be destroyed. If there are several ways to destroy all enemies and break free, print any one. It is guaranteed that there is at least one way to do it.

예제 입력 1

3
2 5 3

예제 출력 1

2 3 5

예제 입력 2

5
-1 1 0 1 -1

예제 출력 2

-1 1 1 -1 0

출처

Contest > Russian Code Cup > 2017 > RCC 2017 Warm-up Round A번

  • 스페셜 저지를 만든 사람: hellogaon