#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void rd(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void wr(T&... args) {
  ((cout << args << " "), ...);
}
int gcd(int a, int b);
int lcm(int a, int b);
long long _sum(vector<int> a);
void Amritesh() {
  int n;
  cin >> n;
  int arr[n];
  for (int(i) = (0); (i) < (n); (i)++) {
    cin >> arr[i];
  }
  int dp[n];
  memset(dp, 0, sizeof(dp));
  dp[0] = arr[0];
  dp[1] = min(arr[0], arr[1]);
  for (int(i) = (2); (i) < (n); (i)++) {
    dp[i] = min(arr[i], (max(dp[i - 1], dp[i - 2])));
  }
  cout << dp[n - 1] << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    Amritesh();
  }
  return 0;
}
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
long long _sum(vector<int> a) { return accumulate(a.begin(), a.end(), 0ll); }
