#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T amax(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;
const long long N = 1e5 + 5;
set<pair<long long, long long> > sets;
long long par[N];
long long sz[N];
long long comps;
void makeset(long long x) {
  par[x] = x;
  sz[x] = 1;
  comps++;
  sets.insert({1, x});
}
long long findset(long long x) {
  if (par[x] == x) return x;
  return par[x] = findset(par[x]);
}
void eraseset(long long x) {
  x = findset(x);
  sets.erase({sz[x], x});
}
void unionsets(long long x, long long y) {
  x = findset(x);
  y = findset(y);
  if (x == y) return;
  eraseset(x);
  eraseset(y);
  par[x] = y;
  sz[y] += sz[x];
  sets.insert({sz[y], y});
  comps--;
}
bool setexists(long long x) { return !!sz[x]; }
bool setsequal() { return sets.begin()->first == sets.rbegin()->first; }
void solve() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > v;
  for (long long i = 1; i < n + 1; i++) {
    long long x;
    cin >> x;
    v.push_back({x, i});
  }
  sort((v).begin(), (v).end());
  long long ans = v[0].first;
  long long ans_comps = 1;
  for (auto x : v) {
    long long val = x.first, id = x.second;
    makeset(id);
    if (setexists(id + 1)) unionsets(id, id + 1);
    if (setexists(id - 1)) unionsets(id, id - 1);
    if (setsequal()) {
      if (comps > ans_comps) {
        ans = val;
        ans_comps = comps;
      }
    }
  }
  cout << ans + 1;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
