Welcome to ZOJ
Select Problem
ZOJ Problem Set - 2059
The Twin Towers

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Twin towers we see you standing tall, though a building's lost our faith will never fall.
Twin towers the world hears your call, though you're gone it only strengthens our resolve.
We couldn't make it through this without you Lord, through hard times we come together more. ...

Twin Towers - A Song for America

In memory of the tragic events that unfolded on the morning of September 11, 2001, five-year-old Rosie decids to rebuild a tallest Twin Towers by using the crystals her brother has collected for years. Will she succeed in building the two towers of the same height?


There are mutiple test cases.

One line forms a test case. The first integer N (N < 100) tells you the number of crystals her brother has collected. Then each of the next N integers describs the height of a certain crystal.

A negtive N indicats the end.

Note that all crytals are in cube shape. And the total height of crystals is smaller than 2000.


If it is impossible, you would say "Sorry", otherwise tell her the height of the Twin Towers.

Sample Input

4 11 11 11 11
4 1 11 111 1111

Sample Output


Author: HU, Shichao
Source: ZOJ Monthly, December 2003
Submit    Status