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