#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 x = ((a[0]) < (a[n - 1]) ? (a[0]) : (a[n - 1]));
  for (int i = 1; i < n - 1; i++) {
    int c = ((a[i]) > (a[i + 1]) ? (a[i]) : (a[i + 1]));
    x = ((x) < (c) ? (x) : (c));
  }
  cout << x;
  return 0;
}
