#include <bits/stdc++.h>
using namespace std;
int ar[10005], i, j, k;
int main() {
  int n;
  while (cin >> n) {
    int m;
    for (i = 1; i <= n; i++) cin >> ar[i];
    m = min(ar[1], ar[n]);
    int mx = 1000000000;
    for (i = 2; i <= n - 2; i++) {
      mx = min(mx, max(ar[i], ar[i + 1]));
    }
    cout << min(mx, m) << endl;
  }
  return 0;
}
