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