#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MOD2 = 998244353;
const long long N = 2e5 + 5;
const long double pi = 3.14159265359;
void SRAND() {
  auto duration = std::chrono::system_clock::now().time_since_epoch();
  auto millis =
      std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
  srand(millis);
}
long long tmp, ans, sz[N], d[N], cnt[N], ma, n;
pair<long long, long long> a[N];
long long f(long long w) { return (d[w] == w ? w : d[w] = f(d[w])); }
void merge(long long ax, long long bx) {
  long long sa = sz[f(ax)], sb = sz[f(bx)];
  cnt[sa]--;
  cnt[sb]--;
  d[f(ax)] = f(bx);
  sz[f(bx)] = sa + sb;
  cnt[sa + sb]++;
  ma = max(ma, sz[f(bx)]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  cnt[0] = n;
  for (long long i = 0; i < N; i++) d[i] = i;
  for (long long i = 1; i <= cnt[0]; i++) {
    cin >> a[a[i].second = i].first;
  }
  sort(a + 1, a + cnt[0] + 1);
  for (long long i = 1; i <= n; i++) {
    sz[a[i].second] = 1;
    ma = max(ma, 1LL);
    cnt[0]--;
    cnt[1]++;
    if (sz[f(a[i].second - 1)]) merge(a[i].second, a[i].second - 1);
    if (sz[f(a[i].second + 1)]) merge(a[i].second, a[i].second + 1);
    if (cnt[ma] * ma == i) {
      if (cnt[ma] > tmp) {
        tmp = cnt[ma];
        ans = a[i].first + 1;
      }
    }
  }
  cout << ans;
  return 0;
}
