#include <bits/stdc++.h>
using namespace std;
int max(int a, int b) {
  if (a > b)
    return a;
  else
    return b;
}
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> v;
  int p = 0;
  v.push_back(a[0]);
  v.push_back(a[n - 1]);
  for (int i = 0; i < n - 2; i++) {
    p = max(a[i + 1], a[i + 2]);
    v.push_back(p);
  }
  sort(v.begin(), v.end());
  cout << v[0] << endl;
}
