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