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