#include <bits/stdc++.h>
using namespace std;
int n, a[1000], mn = 2000;
int main() {
  scanf("%d", &n);
  ;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    ;
  }
  mn = min(mn, min(a[0], a[n - 1]));
  for (int i = 2; i < n - 1; i++) {
    mn = min(mn, max(a[i], a[i - 1]));
  }
  printf("%d\n", mn);
  return 0;
}
