#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int r = 1000000000;
  for (int i = 0; i < n; i++) {
    r = min(r, a[i]);
    if (i == n - 2) continue;
    if (a[i + 1] >= a[i + 2]) {
      continue;
    } else {
      i++;
    }
  }
  cout << r;
}
