I decided to plant vegetables in my vegetable garden. n seeds were available, so I sowed n seeds, one per day, over n days. All the seeds sprouted and are growing very well. We are looking forward to the harvest time.
One day, as I was watering the seedlings as usual, I noticed something strange. There were supposed to be n vegetable seedlings, but there was one too many. A weed has grown up. I want to pull it out immediately, but the trouble is that all the seedlings look so similar that I can't tell the difference between the vegetable and the weed.
The clue is the growth rate of the vegetable. The vegetable continues to grow at a fixed length per day, ever since it was sown. However, we do not know how many centimeters this "fixed length" is. I also forgot how many days ago I sowed the first seed. The seedlings are lined up in a row, and the only thing I remember is that when I sowed the seeds, I sowed them one by one every day, starting from the right.
Create a program that inputs the length of n+1 seedlings and outputs the length of the weed.
The input consists of multiple data sets. The end of the input is indicated by a line with a single zero. The input is given in the following format.
n h1 h2 h3 ... hn+1
The first line, n (4 ≤ n ≤ 100), is an integer representing the number of vegetable seedlings; the second line contains n+1 integers separated by a single space, and hi (1 ≤ hi ≤ 109) indicates the length of the i-th seedling from the left.
No input can be given such that h1 h2 ... hn+1 is an identity sequence.
The number of datasets does not exceed 500.
Output the length of the weed for each dataset.
5 1 2 3 6 4 5 6 1 3 6 9 12 15 18 4 5 7 9 11 12 0
6 1 12