#include <bits/stdc++.h>
using namespace std;
void autocheck() {}
void fast() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
}
const int sz = 1e9 + 7;
int md2(int x, int y) { return ((x * y) % sz); }
int md3(int x, int y, int z) { return md2(x, md2(y, z)); }
int gcd(long long n, long long m) {
  if (n == 0) return m;
  return gcd(m % n, n);
}
int fastm(int a, int b) {
  if (b == 0)
    return 1;
  else if (b % 2 == 1) {
    int temp = fastm(a, (b - 1) / 2);
    return md3(a, temp, temp);
  } else {
    int temp = fastm(a, b / 2);
    return md2(temp, temp);
  }
}
bool comp(pair<int, int> x, pair<int, int> y) {
  return ((x.second > y.second) || (x.second == y.second && x.first > y.first));
}
int main() {
  autocheck();
  fast();
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    vector<int> v(n);
    for (long long i = 0; i < n; i++) cin >> v[i];
    int ans = min(v[0], v[n - 1]);
    for (long long i = 0; i < n - 1; i++) {
      ans = min(ans, max(v[i], v[i + 1]));
    }
    cout << ans << endl;
  }
}
