#include <bits/stdc++.h>
using namespace std;
void appolo() {
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
int a[1006];
int main() {
  appolo();
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i <= 1002; i++) {
    int q = 0;
    for (int j = 0; j < n; j++) {
      if (a[j] < i) {
        a[j] = -1;
        if (j && a[j - 1] == -1) {
          q = 1;
          break;
        }
      }
    }
    if (a[0] == -1 || a[n - 1] == -1 || q) {
      cout << i - 1 << endl;
      break;
    }
  }
}
