#include <bits/stdc++.h>
using namespace std;
int n, in[1005], w[1005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cout << boolalpha << setprecision(6) << fixed;
  clog.copyfmt(cout);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> in[i];
  w[0] = in[0];
  for (int i = 0; i < n; ++i) {
    in[i] = min(in[i], w[i]);
    w[i + 1] = max(in[i], w[i + 1]);
    w[i + 2] = max(in[i], w[i + 2]);
  }
  cout << in[n - 1] << endl;
  return 0;
}
