#include <bits/stdc++.h>
using namespace std;
int n;
struct node {
  int id, a;
} e[1100];
int cmp(node n1, node n2) { return n1.a < n2.a; }
int v[1100];
int main() {
  int ma;
  memset(v, 0, sizeof(v));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &e[i].a);
    e[i].id = i;
  }
  sort(e + 1, e + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    if (e[i].id == 1 || e[i].id == n || v[e[i].id - 1] || v[e[i].id + 1]) {
      ma = e[i].a;
      break;
    }
    v[e[i].id] = 1;
  }
  printf("%d\n", ma);
}
