## DMOPC '14 Contest 7 P2 - Tides

View as PDF

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Tusk has been stranded on an island for some time now, and it's fair to say that he's grown terribly bored. As such, he's started to find ordinary things immensely fascinating.

Today, he's interested in the waves he sees. He notes that at certain times of the day, the water level either increases or decreases. Realizing this phenomenon is due to tides, he is now most fervent about determining the difference in water level between high tide and low tide.

To this end, he's measured the water level times throughout the day using a high-precision measuring device such that each reading is a unique integer in the range inclusive.

He knows that after measuring the absolute minimum reading at low tide, the transition to the absolute maximum reading representing the water level at high tide consists of a strictly increasing sequence of water level readings. He's interested in the difference between the absolute maximum and absolute minimum readings: the water level difference between tides.

It's possible that he made a mistake in writing down these readings, however, in which case the sequence between the low tide reading and high tide reading will not be strictly increasing. If this is the case, it's likely that the data is useless — the water level difference cannot be accurately determined — and should be scrapped.

#### Input Specification

The first line will contain the single integer .

The second line will contain space-separated positive integers: the water level readings in chronological order.

#### Output Specification

The integer difference in water level between high tide and low tide. If the difference cannot be accurately determined, output unknown.

#### Sample Input 1

5
2 1 3 5 10

#### Sample Output 1

9

#### Sample Input 2

5
1 2 5 4 9

#### Sample Output 2

unknown