#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
void in(long long int *a, long long int n) {
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
}
void out(long long int *a, long long int n) {
  for (long long int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
}
unsigned long long int expmod(long long int a, long long int n,
                              long long int M) {
  if (n == 0) return 1;
  if (n == 1) return a;
  unsigned long long int temp = expmod(a, n / 2, M);
  if (n % 2 == 0)
    return ((temp) * (temp)) % M;
  else
    return (a * (temp) * (temp)) % M;
}
int main() {
  fast();
  int tc = 1;
  while (tc--) {
    long long int n;
    cin >> n;
    long long int a[n];
    in(a, n);
    long long int d = a[0];
    for (long long int i = 0; i < n - 2;) {
      if (a[i + 1] < a[i + 2]) {
        d = min(a[i + 2], d);
        i++;
        i++;
      } else {
        d = min(a[i + 1], d);
        i++;
      }
    }
    cout << min(a[0], min(a[n - 1], d)) << "\n";
  }
  return 0;
}
