#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[1010], i, ans;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  ans = min(a[1], a[n]);
  for (i = 1; i < n; i++) {
    if (a[i + 1] > a[i + 2]) {
      ans = min(ans, a[i]);
      ans = min(ans, a[i + 1]);
    } else {
      ans = min(ans, a[i]);
      ans = min(ans, a[i + 2]);
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}
