#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  int mx = INT_MIN;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    mx = max(mx, v[i]);
  }
  if (n == 1)
    cout << v[0];
  else {
    int ans = 0, flag = 0;
    for (int j = 0; j < mx; j++) {
      for (int i = 0; i < n; i++) {
        if (v[i]) {
          v[i]--;
        }
      }
      for (int k = 0; k < n - 1; k++) {
        if (v[0] == 0 || v[n - 1] == 0) {
          flag = 1;
          ans = j + 1;
          break;
        } else {
          if (v[k] == 0 && v[k + 1] == 0) {
            ans = j + 1;
            flag = 1;
            break;
          }
        }
      }
      if (flag) break;
    }
    cout << ans;
  }
  return 0;
}
