#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int n, m;
int a[N];
int v[N];
void dfs(int x) {
  v[x] = 1;
  if (x + 1 <= n && m <= a[x + 1] && !v[x + 1]) dfs(x + 1);
  if (x + 2 <= n && m <= a[x + 2] && !v[x + 2]) dfs(x + 2);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  int l = 1, r = 1001, ans = 0;
  while (l <= r) {
    m = l + r >> 1;
    memset(v, 0, sizeof(v));
    if (m <= a[1]) dfs(1);
    if (v[n])
      ans = m, l = m + 1;
    else
      r = m - 1;
  }
  printf("%d\n", ans);
}
