#include <bits/stdc++.h>
using namespace std;
long long moduloMultiplication(long long a, long long b, long long mod) {
  long long res = 0;
  a %= mod;
  while (b) {
    if (b & 1) res = (res + a) % mod;
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}
bool IsPowerOfTwo(long long x) { return (x != 0) && ((x & (x - 1)) == 0); }
bool possible(vector<long long>& arr, long long i, vector<long long>& dp) {
  if (i == arr.size() - 1) {
    if (arr[i] < 0)
      return 0;
    else
      return 1;
  }
  if (i >= arr.size()) return 0;
  if (dp[i] != -1) return dp[i];
  if (arr[i] < 0) return 0;
  return dp[i] = possible(arr, i + 1, dp) || possible(arr, i + 2, dp);
}
bool possibleHelper(vector<long long>& arr) {
  vector<long long> dp(arr.size() + 1, -1);
  return possible(arr, 0, dp);
}
void solve(long long test_case) {
  long long n;
  cin >> n;
  vector<long long> arr(n);
  priority_queue<long long> minQ;
  for (int i = 0; i < n; i += 1) {
    cin >> arr[i];
    minQ.push(-arr[i]);
  }
  if (n == 1) {
    cout << arr.front();
    return;
  }
  reverse(arr.begin(), arr.end());
  long long days = 0;
  long long prev = 0;
  while (possibleHelper(arr) && minQ.size()) {
    prev = days;
    long long diff = (-minQ.top() - days);
    days = -minQ.top();
    minQ.pop();
    for (int i = 0; i < n; i += 1) arr[i] -= diff;
  }
  cout << prev;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t, t1 = 0;
  solve(t1 + 1);
}
