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