#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int k = min(a[0], a[n - 1]);
  int i = 0;
  while (i < n - 1 && n) {
    if (a[i + 1] > a[i + 2]) {
      k = min(k, a[i + 1]);
      i++;
    } else if (a[i + 1] < a[i + 2]) {
      k = min(k, a[i + 2]);
      i += 2;
    } else if (a[i + 1] == a[i + 2]) {
      k = min(k, a[i + 2]);
      i += 2;
    }
  }
  cout << k << endl;
}
