#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int dp[10000];
  for (int i = 0; i < n; i++) cin >> dp[i];
  dp[1] = min(dp[1], dp[0]);
  for (int i = 2; i < n; i++) dp[i] = min(dp[i], max(dp[i - 1], dp[i - 2]));
  cout << dp[n - 1] << endl;
  return 0;
}
