#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int dp[1002];
  for (int i = 1; i <= n; ++i) {
    int tmp;
    cin >> dp[i];
  }
  dp[0] = 0;
  for (int i = 2; i <= n; ++i) {
    int tmp = (dp[i - 1] < dp[i - 2]) ? dp[i - 2] : dp[i - 1];
    dp[i] = dp[i] < tmp ? dp[i] : tmp;
  }
  cout << dp[n] << endl;
}
