#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n + 2);
  for (int i = 1; i <= n; i++) cin >> v[i];
  bool flag = 1;
  int ma = v[1];
  int i = 1;
  while (i != n) {
    if (i + 1 == n) {
      ma = min(ma, v[n]);
      i++;
    } else if (v[i + 1] > v[i + 2]) {
      ma = min(ma, v[i + 1]);
      i++;
    } else {
      ma = min(ma, v[i + 2]);
      i += 2;
    }
  }
  if (flag == 1)
    cout << ma << endl;
  else
    cout << 0 << endl;
}
