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;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  ;
  vector<int> p(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  };
  if (n == 1) {
    cout << 1;
    return 0;
  }
  vector<int> init(n + 1, 0);
  init[1] = 1;
  int maxi = p[1];
  int cnti = 0;
  for (int i = 2; i <= n; i++) {
    if (p[i] > maxi) {
      init[i] = 1;
      cnti++;
    }
    maxi = max(maxi, p[i]);
  }
  vector<int> cnt(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    if (init[i]) {
      cnt[p[i]] = -1;
    }
  }
  int maxi1, maxi2;
  if (p[2] > p[1]) {
    maxi1 = p[2];
    maxi2 = p[1];
  } else {
    maxi1 = p[1];
    maxi2 = p[2];
    cnt[p[1]]++;
  };
  for (int i = 3; i <= n; i++) {
    ;
    if ((p[i] < maxi1) && (p[i] > maxi2)) {
      ;
      cnt[maxi1]++;
    }
    if (p[i] > maxi1) {
      maxi2 = maxi1;
      maxi1 = p[i];
      continue;
    }
    if (p[i] > maxi2) maxi2 = p[i];
  };
  int maxans = -INT_MAX;
  for (int i = 1; i <= n; i++) maxans = max(maxans, cnt[i]);
  for (int i = 1; i <= n; i++) {
    if (cnt[i] == maxans) {
      cout << i;
      return 0;
    }
  }
  return 0;
}
