#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
pair<int, int> b[N];
int cnt[N], f[N], size[N], n, tot = 0;
int find(int x) {
  if (f[x] != x) f[x] = find(f[x]);
  return f[x];
}
void init(int x) {
  f[x] = x;
  size[x] = 1;
  cnt[1]++;
  ++tot;
}
void merge(int x, int y) {
  if (!f[x] || !f[y]) return;
  x = find(x);
  y = find(y);
  cnt[size[x]]--;
  cnt[size[y]]--;
  f[x] = y;
  size[y] += size[x];
  cnt[size[y]]++;
  --tot;
}
int main() {
  scanf("%d", &n);
  int ans = 2e9, ma = 0, x;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    b[i] = {x, i};
  }
  sort(b + 1, b + n + 1);
  for (int i = 1; i <= n; ++i) {
    x = b[i].second;
    init(x);
    merge(x - 1, x);
    merge(x, x + 1);
    if (cnt[size[find(x)]] == tot) {
      if (tot > ma)
        ma = tot, ans = b[i].first + 1;
      else if (tot == ma)
        ans = min(ans, b[i].first + 1);
    }
  }
  printf("%d\n", ans);
  return 0;
}
