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