#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for (int &i : a) std::cin >> i;
  if (n == 1)
    std::cout << a[0] << std::endl;
  else {
    if (a[1] > a[0]) a[1] = a[0];
    for (int i = 2; i < n; ++i) {
      int t = std::max(a[i - 1], a[i - 2]);
      if (t < a[i]) a[i] = t;
    }
    std::cout << a[n - 1] << std::endl;
  }
  return 0;
}
