#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *a = new int[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int m = min(a[0], a[n - 1]);
  for (int i = 1; i < n - 2; i++)
    if (max(a[i], a[i + 1]) < m) m = max(a[i], a[i + 1]);
  cout << m;
  return 0;
}
