#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  int i = 0;
  vector<int> ans;
  ans.push_back(v[0]);
  ans.push_back(v[n - 1]);
  while (i < n - 3) {
    int k = v[i + 1];
    int l = v[i + 2];
    if (l >= k) {
      ans.push_back(l);
      i = i + 2;
    } else {
      ans.push_back(k);
      i++;
    }
  }
  int out = *min_element(ans.begin(), ans.end());
  cout << out;
  return 0;
}
