#pragma comment(linker, "/STACK:102400000,102400000")
//#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
#include<set>
#include <utility>
#include<stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define mst(a) memset(a, 0, sizeof(a))
#define M_P(x,y) make_pair(x,y)
#define rep(i,j,k) for (int i = j; i <= k; i++)
#define per(i,j,k) for (int i = j; i >= k; i--)
#define lson x << 1, l, mid
#define rson x << 1 | 1, mid + 1, r
const int lowbit(int x) { return x&-x; }
const double eps = 1e-8;
const int INF = 1e9+7;
const ll inf =(1LL<<62) ;
const int MOD = 1e9 + 7;
const ll mod = (1LL<<32);
const int N = 1010;
const int M=100010;
template <class T1, class T2>inline void getmax(T1 &a, T2 b) {if(b>a)a = b;}
template <class T1, class T2>inline void getmin(T1 &a, T2 b) {if(b<a)a = b;}
int read()
{
int v = 0, f = 1;
char c =getchar();
while( c < 48 || 57 < c ){
if(c=='-') f = -1;
c = getchar();
}
while(48 <= c && c <= 57)
v = v*10+c-48, c = getchar();
return v*f;
}
int a[50001];
int f[50001][16];
int n;
void RMQ_init() //建立: dp(i,j) = min{dp(i,j-1),dp(i+2^(j-1),j-1):O(nlogn)
{
for(int i=1; i<=n; i++)
f[i][0] = a[i];
int k=floor(log((double)n)/log(2.0)); //C/C++取整函数ceil()大,floor()小
for(int j=1; j<=k; j++)
for(int i=1;i<=n;i++)
//for(int i=n; i>=1; i--) //有些题能AC,有些不能
{
if(i+(1<<j)-1<=n) //f(i,j) = min{f(i,j-1),f(i+2^(j-1),j-1)
f[i][j]=min(f[i][j-1],f[i+(1<<(j-1))][j-1]);
}
}
int RMQ(int i,int j) //查询:返回区间[i,j]的最小值:O(1)
{
int k = floor(log((double)(j-i+1))/log(2.0));
return min(f[i][k],f[j-(1<<k)+1][k]);
}
int main()
{
scanf("%d",&n);
for(int i=1; i<=n; i++)
scanf("%d",&a[i]);
RMQ_init();
printf("%d\n",RMQ(2,5));
return 0;
}