#include <bits/stdc++.h>
using namespace std;
template <class T>
T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <class T>
T min(T a, T b, T c, T d) {
  return min(a, min(b, min(c, d)));
}
template <class T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
template <class T>
T max(T a, T b, T c, T d) {
  return max(a, max(b, max(c, d)));
}
bool cmp(const int &a, const int &b) { return a > b; }
long long GCD(long long a, long long b) { return (a % b) ? GCD(b, a % b) : b; }
bool step[100007];
int a[100007];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) scanf("%d", &a[i]);
  for (int i = (1); i <= (1001); ++i) {
    for (int j = (1); j <= (n); ++j) step[j] = 0;
    if (i < a[1]) step[1] = 1;
    for (int j = (2); j <= (n); ++j) {
      if (i >= a[j]) continue;
      if (step[j - 1] || step[j - 2]) step[j] = 1;
    }
    if (!step[n]) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}
