#include <bits/stdc++.h>
using namespace std;
int di[] = {1, 0, -1, 0};
int dj[] = {0, 1, 0, -1};
int a[10000];
int main(int argc, char *argv[]) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  int ans;
  for (ans = 1;; ans++) {
    if (a[0] < ans || a[n - 1] < ans) break;
    bool ex = 0;
    for (int i = 0; i < n - 2; ++i) {
      if (a[i + 1] < ans && a[i + 2] < ans) {
        ex = 1;
        break;
      }
    }
    if (ex) break;
  }
  cout << ans - 1;
  return 0;
}
