#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[100005];
vector<long long> v;
map<long long, long long> rev;
multiset<long long> diffs;
set<long long> pts;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    rev[a[i]] = i;
    v.push_back(a[i]);
  }
  sort(v.begin(), v.end());
  pts.insert(0);
  pts.insert(n + 1);
  long long ans = -1;
  long long best = 1;
  diffs.insert(n + 1);
  for (long long i = (v.size() - 1); i >= 0; i--) {
    long long npt = rev[v[i]];
    if (i == 0) {
      if (best <= 1) {
        ans = -1;
        break;
      }
      break;
    }
    auto it = pts.lower_bound(npt);
    auto it2 = it;
    it2--;
    if (diffs.find(*it - *it2) != diffs.end()) {
      diffs.erase(diffs.find(*it - *it2));
      if (*it - npt > 1) diffs.insert(*it - npt);
      if (npt - *it2 > 1) diffs.insert(npt - *it2);
    }
    long long MI = *diffs.begin();
    auto itx = diffs.end();
    itx--;
    long long MA = *itx;
    if (MI == MA && (MI > 1)) {
      long long days = MI - 1;
      if (i / days >= best) {
        best = i / days;
        ans = i;
      }
    }
    pts.insert(npt);
  }
  if (ans == -1) {
    ans = 1;
  }
  cout << v[ans - 1] + 1 << endl;
  return 0;
}
