#include <bits/stdc++.h>
using namespace std;
struct rain {
  int a;
  int d;
} r[1020];
int n;
int flag[1020];
int main() {
  scanf("%d", &n);
  memset(flag, 0, sizeof(flag));
  for (int i = 1; i <= n; i++) {
    scanf("%d", &r[i].d);
    r[i].a = i;
  }
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) {
      if (r[i].d > r[j].d) {
        rain t = r[i];
        r[i] = r[j];
        r[j] = t;
      }
    }
  int day = 0;
  for (int i = 1; i <= n; i++) {
    if (r[i].a == 1 || r[i].a == n) {
      day = r[i].d;
      break;
    }
    if (flag[r[i].a + 1] == 0 && flag[r[i].a - 1] == 0) {
      day = r[i].d;
      flag[r[i].a] = 1;
    } else {
      day = r[i].d;
      break;
    }
  }
  printf("%d\n", day);
  return 0;
}
