#include <bits/stdc++.h>
using namespace std;
signed main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x;
  cin >> n;
  vector<int> v;
  set<int> s;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
    s.insert(x);
  }
  if (n == 2) {
    cout << *min_element(v.begin(), v.end());
    return 0;
  }
  for (auto it = s.begin(); it != s.end(); it++) {
    int destroyed = *it;
    int flag = 0, i = 0;
    while (i < n - 2) {
      if (v[0] < destroyed || v[n - 1] < destroyed) {
        flag = 1;
        break;
      }
      if (v[i + 1] < destroyed && v[i + 2] < destroyed) {
        flag = 1;
        break;
      } else if (v[i + 2] >= destroyed)
        i += 2;
      else if (v[i + 1] >= destroyed)
        i++;
    }
    if (flag == 1) {
      it--;
      cout << *it;
      return 0;
    }
  }
  cout << *max_element(v.begin(), v.end());
  return 0;
}
