#include <bits/stdc++.h>
using namespace std;
bool Walking(int Array[], int ArraySize) {
  bool Pass = true;
  if (Array[0] == 1111 || Array[ArraySize - 1] == 1111) Pass = false;
  for (int i = 0; i < ArraySize - 1 && Pass; i++) {
    if (Array[i] == 1111 && Array[i + 1] == 1111) Pass = false;
  }
  return Pass;
}
int GetMinIndex(int Array[], int ArraySize) {
  int Min = 1111, Index;
  for (int i = 0; i < ArraySize; i++) {
    if (Array[i] < Min) {
      Min = Array[i];
      Index = i;
    }
  }
  return Index;
}
int main() {
  int Tiles, RemainingTime;
  cin >> Tiles;
  int BreakingTime[Tiles];
  for (int i = 0; i < Tiles; i++) cin >> BreakingTime[i];
  while (Walking(BreakingTime, Tiles)) {
    RemainingTime = BreakingTime[GetMinIndex(BreakingTime, Tiles)];
    BreakingTime[GetMinIndex(BreakingTime, Tiles)] = 1111;
  }
  cout << RemainingTime << endl;
  return 0;
}
