#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> vec;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    vec.push_back(tmp);
  }
  int it = 0;
  int final = vec[it];
  while (it < n) {
    if (it + 2 < n && it + 1 < n) {
      if (vec[it + 2] < vec[it + 1]) {
        if (final > vec[it + 1]) {
          final = vec[it + 1];
        }
        it = it + 1;
      } else {
        if (final > vec[it + 2]) {
          final = vec[it + 2];
        }
        it = it + 2;
      }
    } else if (it + 1 < n) {
      if (final > vec[it + 1]) {
        final = vec[it + 1];
        it++;
      } else {
        it++;
      }
    } else {
      it++;
    }
  }
  cout << final;
  return 0;
}
