#include <bits/stdc++.h>
using namespace std;
void SR(int &x) { scanf("%d", &x); }
void SR(long long &x) { scanf("%lld", &x); }
void SR(double &x) { scanf("%lf", &x); }
void SR(char *s) { scanf("%s", s); }
void RI() {}
template <typename I, typename... T>
void RI(I &x, T &...tail) {
  SR(x);
  RI(tail...);
}
const int maxn = 1e3 + 3;
int ar[maxn], n;
void read() {
  RI(n);
  for (int i = 0; i < int(n); i++) RI(ar[i]);
}
void build() { reverse(ar, ar + n); }
bool test(int k) {
  bitset<maxn> v;
  v[0] = (ar[0] >= k);
  for (int i = 0; i < int(n); i++)
    if (ar[i] >= k) {
      if (ar[i + 1] >= k) v[i + 1] = v[i + 1] | v[i];
      if (ar[i + 2] >= k) v[i + 2] = v[i + 2] | v[i];
    }
  return v[n - 1];
}
void sol() {
  int l = 1, r = maxn;
  while (r > l) {
    int mid = (l + r + 1) / 2;
    if (test(mid))
      l = mid;
    else
      r = mid - 1;
  }
  printf("%d\n", l);
}
int main() {
  read();
  build();
  sol();
  return 0;
}
