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