#include <bits/stdc++.h>
using namespace std;
const long long mod1 = 1000000007;
const long long mod9 = 998244353;
long long powmod(long long a, long long b, long long mod = mod1) {
  long long ans = 1;
  while (b--) {
    ans = (ans * a) % mod;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  long long tmp;
  while (b) {
    tmp = a;
    a = b;
    b = tmp % b;
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    ;
    vector<long long> arr;
    for (long long i = 0; 0 < n ? i < n : i > n; 0 < n ? i++ : i--) {
      long long k;
      cin >> k;
      arr.push_back(k);
    };
    long long mn = mod1;
    for (long long i = 0; 0 < n - 1 ? i < n - 1 : i > n - 1;
         0 < n - 1 ? i++ : i--) {
      mn = min(mn, max(arr[i], arr[i + 1]));
    }
    long long x = min(arr[0], arr[n - 1]);
    cout << (min(x, mn)) << "\n";
    ;
  }
  return 0;
}
