#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> vals(n);
  for (int i = 0; i < n; i++) cin >> vals[i];
  int ans = min(vals[0], vals[n - 1]);
  for (int i = 1; i < n; i++) ans = min(ans, max(vals[i], vals[i - 1]));
  cout << ans << endl;
  return 0;
}
