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;
bool bit(int n, int i) { return (n >> i) & 1; }
int faltu;
const int mod = 1e9 + 7;
const long long MAX = 4e18;
const long long MIN = -MAX;
const int imax = 2e9 + 100;
const int maxn = 1e5 + 10;
pair<int, int> stree[maxn * 4];
pair<int, int> operator+(const pair<int, int> a, const pair<int, int> b) {
  if (a.first == 0) {
    return b;
  } else {
    return {a.first + b.first, a.second};
  }
}
void update(int i, int j, int sidx, int idx) {
  if (i > idx or j < idx) {
    return;
  } else if (i == idx and j == idx) {
    stree[sidx] = {1, i};
    return;
  }
  update(i, ((i + j) >> 1), sidx * 2, idx);
  update(((i + j) >> 1) + 1, j, sidx * 2 + 1, idx);
  stree[sidx] = stree[sidx * 2] + stree[sidx * 2 + 1];
}
pair<int, int> query(int i, int j, int sidx, int ql, int qr) {
  if (i > qr or j < ql) {
    return {0, -1};
  } else if (i >= ql and qr >= j) {
    return stree[sidx];
  } else {
    return query(i, ((i + j) >> 1), sidx * 2, ql, qr) +
           query(((i + j) >> 1) + 1, j, sidx * 2 + 1, ql, qr);
  }
}
int main() {
  time_t t1, t2;
  t1 = clock();
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    assert(a[i] <= n);
  }
  int counter[n + 1];
  bool is_record[n + 1];
  memset(is_record, 0, sizeof(is_record));
  memset(counter, 0, sizeof(counter));
  for (int i = 1; i <= n; i++) {
    update(1, n, 1, a[i]);
    pair<int, int> sum = query(1, n, 1, a[i] + 1, n);
    if (sum.first == 1) {
      counter[sum.second]++;
    } else if (sum.first == 0) {
      counter[a[i]]--;
    }
  }
  int mx = *max_element(counter + 1, counter + n + 1);
  for (int i = 1; i <= n; i++) {
    if (counter[i] == mx) {
      cout << i << endl;
      return 0;
    }
  }
  cerr << endl;
  t2 = clock();
  cerr << "time taken: " << t2 - t1 << endl;
  return 0;
}
