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