#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1003;
int a[MAXN];
bool DP[MAXN];
int n;
bool ok(int x) {
  for (int i = 0; i < n; i++) a[i] -= x;
  if (a[n - 1] < 0 || a[0] < 0) {
    for (int i = 0; i < n; i++) a[i] += x;
    return false;
  }
  DP[0] = true;
  for (int i = 1; i < n; i++)
    if (a[i] < 0)
      DP[i] = false;
    else {
      DP[i] = DP[i - 1];
      if (i > 1) DP[i] |= DP[i - 2];
    }
  for (int i = 0; i < n; i++) a[i] += x;
  return DP[n - 1];
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int lo = 0, hi = 1000, res = -1;
  while (lo <= hi) {
    int mid = (lo + hi) >> 1;
    if (ok(mid))
      res = mid, lo = mid + 1;
    else
      hi = mid - 1;
  }
  cout << res;
  return 0;
}
