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