#include <bits/stdc++.h>
using namespace std;
int arr[1009];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 1; i <= 1001; i++) {
    if (arr[0] < i || arr[n - 1] < i) {
      cout << i - 1 << endl;
      return 0;
    }
    for (int pos = 0; pos < n - 1;) {
      if (arr[pos + 1] >= i)
        pos++;
      else if (arr[pos + 2] >= i)
        pos += 2;
      else {
        cout << i - 1 << endl;
        return 0;
      }
    }
  }
  return 0;
}
