#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long tt = 1;
  while (tt--) {
    long long n;
    cin >> n;
    long long arr[n + 1];
    for (long long i = 0; i < n; i++) cin >> arr[i];
    arr[n] = arr[n - 1];
    long long mx = -1;
    long long ans = INT_MAX;
    for (long long i = 0; i < n; i++) {
      mx = max(arr[i], arr[i + 1]);
      ans = min(ans, mx);
    }
    cout << min({ans, arr[0], arr[n]});
    cout << '\n';
  }
  return 0;
}
