Shark

TimeLimit:1000MS  MemoryLimit:256MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

For long time scientists study the behavior of sharks. Sharks, as many other species, alternate short movements in a certain location and long movements between locations.

Max is a young biologist. For  days he watched a specific shark, and now he knows the distance the shark traveled in each of the days. All the distances are distinct. Max wants to know now how many locations the shark visited. He assumed there is such an integer  that if the shark in some day traveled the distance strictly less than , then it didn't change the location; otherwise, if in one day the shark traveled the distance greater than or equal to ; then it was changing a location in that day. Note that it is possible that the shark changed a location for several consecutive days, in each of them the shark traveled the distance at least .

The shark never returned to the same location after it has moved from it. Thus, in the sequence of  days we can find consecutive nonempty segments when the shark traveled the distance less than  in each of the days: each such segment corresponds to one location. Max wants to choose such  that the lengths of all such segments are equal.

Find such integer , that the number of locations is as large as possible. If there are several such , print the smallest one.


Input

The first line contains a single integer n () — the number of days.

The second line contains  distinct positive integers  () — the distance traveled in each of the day.


Output

Print a single integer , such that

  1. the shark was in each location the same number of days,

  2. the number of locations is maximum possible satisfying the first condition,

  3.  is smallest possible satisfying the first and second conditions.


SampleInput 1
8
1 2 7 3 4 8 5 6
SampleOutput 1
7
SampleInput 2
6
25 1 2 3 14 36
SampleOutput 2
2
Note

In the first example the shark travels inside a location on days 1 and 2 (first location), then on 4-th and 5-th days (second location), then on 7-th and 8-th days (third location). There are three locations in total. In the second example the shark only moves inside a location on the 2-nd day, so there is only one location.

Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: