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.
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.TreeSet;

/*
 public class _900C {

 }

 */
public class _900C {
  class BinaryIndexedTree {
    int n;
    int[] tree;

    public BinaryIndexedTree(int n) {
      super();
      this.n = n;
      this.tree = new int[n + 1];
    }

    public int sum(int idx) {
      int sum = 0;

      while (idx > 0) {
        sum += tree[idx];
        idx -= (idx & -idx);
      }

      return sum;
    }

    public void update(int idx, int v) {
      while (idx <= n) {
        tree[idx] += v;
        idx += (idx & -idx);
      }
    }
  }

  public void solve() throws FileNotFoundException {
    InputStream inputStream = System.in;

    InputHelper in = new InputHelper(inputStream);

    // actual solution
    int n = in.readInteger();

    int[] p = new int[n];;

    for (int i = 0; i < n; i++) {
      p[i] = in.readInteger();
    }

    int[] h = new int[n + 1];

    BinaryIndexedTree bit = new BinaryIndexedTree(n + 1);
    TreeSet<Integer> ts = new TreeSet<Integer>();

    for (int i = 0; i < n; i++) {
      int acnt = i;
      int scnt = bit.sum(p[i] - 1);
      if (scnt == acnt) {
        h[p[i]]--;
      }
      if (scnt == acnt - 1) {
        int num = ts.ceiling(p[i] + 1);
        h[num]++;
      }
      bit.update(p[i], 1);
      ts.add(p[i]);
    }

    List<ele> elel = new ArrayList<_900C.ele>();

    for (int i = 1; i <= n; i++) {
      elel.add(new ele(i, h[i]));
    }

    elel.sort((e1, e2) -> {
      if (e1.blm == e2.blm) {
        return e1.num - e2.num;
      } else {
        return e2.blm - e1.blm;
      }
    });

    System.out.println(elel.get(0).num);
    // end here
  }

  class ele {
    int num;
    int blm;

    /**
     * @param num
     * @param blm
     */
    public ele(int num, int blm) {
      super();
      this.num = num;
      this.blm = blm;
    }


  }

  public static void main(String[] args) throws FileNotFoundException {
    (new _900C()).solve();
  }

  class InputHelper {
    StringTokenizer tokenizer = null;
    private BufferedReader bufferedReader;

    public InputHelper(InputStream inputStream) {
      InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
      bufferedReader = new BufferedReader(inputStreamReader, 16384);
    }

    public String read() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          String line = bufferedReader.readLine();
          if (line == null) {
            return null;
          }
          tokenizer = new StringTokenizer(line);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      return tokenizer.nextToken();
    }

    public Integer readInteger() {
      return Integer.parseInt(read());
    }

    public Long readLong() {
      return Long.parseLong(read());
    }
  }
}
