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>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
long long qmod(long long a, long long n, long long mod) {
  long long ans = 1;
  while (n) {
    if (n & 1ll) {
      ans = ans * a % mod;
    }
    n >>= 1;
    a = a * a % mod;
  }
  return ans;
}
template <class T>
inline T lowbit(T x) {
  return x & -x;
}
template <class T>
inline T sqr(T x) {
  return (x) * (x);
}
template <class T>
inline T my_pow(T a, T n) {
  T ans = 1;
  while (n) {
    if (n & 1ll) {
      ans = ans * a;
    }
    n >>= 1;
    a = a * a;
  }
  return ans;
}
template <class T>
inline T My_Find(T x, T a[], T l, T r) {
  int mid, ans = -1;
  while (l <= r) {
    mid = l + r >> 1;
    if (a[mid] > x)
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  return ans;
}
template <class T>
inline bool scan(T& ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
struct FastIO {
  static const int S = 100 << 1;
  int wpos;
  char wbuf[S];
  FastIO() : wpos(0) {}
  inline int xchar() {
    static char buf[S];
    static int len = 0, pos = 0;
    if (pos == len) {
      pos = 0;
      len = (int)fread(buf, 1, S, stdin);
    }
    if (pos == len) {
      return -1;
    }
    return buf[pos++];
  }
  inline int xint() {
    int s = 1, c = xchar(), x = 0;
    while (c <= 32) {
      c = xchar();
    }
    if (c == '-') {
      s = -1;
      c = xchar();
    }
    for (; '0' <= c && c <= '9'; c = xchar()) {
      x = x * 10 + c - '0';
    }
    return x * s;
  }
  ~FastIO() {
    if (wpos) {
      fwrite(wbuf, 1, wpos, stdout);
      wpos = 0;
    }
  }
} io;
const long long mod = 1e9 + 7;
const double pi = 3.14159265358979323846264338327950288L;
const long double eps = 1e-12;
const int INF = 0x3f3f3f3f;
const int maxn = 100005;
const int maxm = 10000005;
int a[maxn];
int main() {
  int n;
  cin >> n;
  int max1 = 0, max2 = 0;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    if (x > max1) {
      max2 = max1;
      max1 = x;
      a[x]--;
    } else if (x > max2) {
      max2 = x;
      a[max1]++;
    }
  }
  int mini = -INF, ans = -1;
  for (int i = 1; i <= n; ++i) {
    if (a[i] > mini) {
      mini = a[i];
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}
