#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> v(n + 1);
  v[0] = INT_MAX;
  for (int i = 1; i <= n; i++) cin >> v[i];
  vector<int> dp(n + 1, 0);
  dp[1] = v[1];
  dp[2] = min(v[2], dp[1]);
  for (int i = 3; i <= n; i++) {
    dp[i] = max(min(v[i], dp[i - 1]), min(v[i], dp[i - 2]));
  }
  cout << dp[n];
  return 0;
}
