#include <bits/stdc++.h>
using namespace std;
long long a[1050], tmp, n, ans;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  ans = a[0];
  a[n] = -1;
  a[n + 1] = -1;
  long long i = 0;
  while (i < n - 1) {
    if (a[i + 1] > a[i + 2]) {
      i++;
      ans = min(ans, a[i]);
    } else {
      i += 2;
      ans = min(ans, a[i]);
    }
  }
  cout << ans;
}
