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