You 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 a1, a2, ..., ak the element ai is a record if for every integer j (1 ≤ j < i) the following holds: aj < ai. 

Input

The first line contains the only integer n (1 ≤ n ≤ 105) — the length of the permutation.

The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 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.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 21;
const int N = int(1e5);
const long long mod = int(1e9) + 7;
const long long inf = 1e18;
const double PI = 3.1415926536;
inline int Set(int n, int pos) { return n = n | 1 << pos; }
inline bool check(int n, int pos) { return n & 1 << pos; }
inline int Reset(int n, int pos) { return n = n & ~(1 << pos); }
inline int lastbit(int n) { return n & (-n); }
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return (a * b) / gcd(a, b); }
inline long long power(long long a, long long b) {
  long long ans = 1;
  a = a % mod;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    b >>= 1;
    a = (a * a) % mod;
  }
  return ans;
}
inline long long invmod(long long a) {
  long long ans = power(a, mod - 2);
  return ans;
}
inline long long Egcd(long long a, long long b, long long *x, long long *y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long x1, y1;
  long long gcd = Egcd(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
inline int bs(int arr[], int l, int r, int item) {
  if (l == r) {
    if (arr[l] == item)
      return r;
    else
      return -1;
  }
  if (item <= arr[(l + r) / 2])
    return bs(arr, l, (l + r) / 2, item);
  else
    return bs(arr, (l + r) / 2 + 1, r, item);
}
inline void fastin(int &x) {
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return;
}
int cnt[(int)1e5 + 30];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, x;
  cin >> n;
  int max1 = -1e9, max2 = -1e9;
  for (int i = 1; i < n + 1; i++) {
    cin >> x;
    if (x > max1)
      max2 = max1, max1 = x, cnt[x]--;
    else if (x > max2)
      cnt[max1]++, max2 = x;
  }
  int ans = 1;
  for (int i = 1; i < n + 1; i++) {
    if (cnt[i] > cnt[ans]) ans = i;
  }
  cout << ans;
  return 0;
}
