#include<cstdio>
#include<cstring>
#include<iostream>
#define MM 101010
#define Min(x,y) x<y?x:y
using namespace std;
int a[MM],d[MM][15];
int n,q;
void RMQ_init()
{
int i,j;
for(i=1;i<=n;i++)
d[i][0]=a[i];
for(j=1;(1<<j)<=n;j++)
{
for(i=1;(i+(1<<j)-1)<=n;i++)
d[i][j]=Min(d[i][j-1],d[i+(1<<(j-1))][j-1]);
}
}
int RMQ(int l,int r)
{
int k=0;
while((1<<(k+1))<=r-l+1)k++;
return Min(d[l][k],d[r-(1<<k)+1][k]);
}
int main()
{
int i,j;
//freopen("D:\\o.txt","r",stdin);
while(~scanf("%d",&n))
{
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
RMQ_init();
scanf("%d",&q);
while(q--)
{
int r,l;
scanf("%d%d",&l,&r);
printf("%d\n",RMQ(l,r));
}
}
return 0;
}