#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[1000];
bool safe[1000];
int n;
int main() {
  memset(safe, false, sizeof(safe));
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    safe[a[i].second] = true;
    if (a[i].second == 0 || a[i].second == n - 1) {
      cout << a[i].first;
      return 0;
    }
    if (safe[a[i].second - 1] || safe[a[i].second + 1]) {
      cout << a[i].first;
      return 0;
    }
  }
  return 0;
}
