#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9;
const double EPS = 1e-6;
const double PI = 3.1415926535;
const int MOD = 1000003;
int a[1001], dp[1001];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i + 1];
  dp[1] = a[1];
  for (int i = 2; i <= n; ++i) dp[i] = min(max(dp[i - 1], dp[i - 2]), a[i]);
  cout << dp[n];
  return 0;
}
