#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n;
  cin >> n;
  long long a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> v;
  v.push_back(a[0]);
  for (i = 1; i < n - 1; i++) {
    if (a[i] > a[i + 1]) {
      v.push_back(a[i]);
    } else {
      v.push_back(a[i + 1]);
      i++;
    }
  }
  if (v[v.size() - 1] != a[n - 1]) v.push_back(a[n - 1]);
  long long min = INT_MAX;
  for (i = 0; i < v.size(); i++) {
    if (min > v[i]) min = v[i];
  }
  cout << min << endl;
  return 0;
}
