Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

C. Remove Extra One

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou are given a permutation *p* of length *n*. Remove one element from permutation to make the number of records the maximum possible.

We remind that in a sequence of numbers *a*_{1}, *a*_{2}, ..., *a*_{k} the element *a*_{i} is a record if for every integer *j* (1 ≤ *j* < *i*) the following holds: *a*_{j} < *a*_{i}.

Input

The first line contains the only integer *n* (1 ≤ *n* ≤ 10^{5}) — the length of the permutation.

The second line contains *n* integers *p*_{1}, *p*_{2}, ..., *p*_{n} (1 ≤ *p*_{i} ≤ *n*) — the permutation. All the integers are distinct.

Output

Print the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.

Examples

Input

1

1

Output

1

Input

5

5 1 2 3 4

Output

5

Note

In the first example the only element can be removed.

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/18/2019 18:27:59 (f2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|