#include"iostream"
using namespace std;
const int maxn=1e6+5;
struct AAA
{
    int mx,mi;
};
AAA a[maxn][20];
int N,M;
void RMQ_ST()
{
    for(int k=1;(1<<k)<=N;k++)
    {
        for(int i=1;i+(1<<k)-1<=N;i++)
        {
            a[i][k].mx=max(a[i][k-1].mx,a[i+(1<<(k-1))][k-1].mx);
            a[i][k].mi=min(a[i][k-1].mi,a[i+(1<<(k-1))][k-1].mi);
        }
    }
}
int qmax(int L,int R)
{
    int k=0;
    while((1<<(k+1))<=R-L+1)k++;
    return max(a[L][k].mx,a[R-(1<<k)+1][k].mx);
}
int qmin(int L,int R)
{
    int k=0;
    while((1<<(k+1))<=R-L+1)k++;
    return min(a[L][k].mi,a[R-(1<<k)+1][k].mi);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>N;
    for(int i=1;i<=N;i++)
    {
        cin>>a[i][0].mx;
        a[i][0].mi=a[i][0].mx;
    }
    RMQ_ST();
    cin>>M;
    int L,R;
    for(int i=1;i<=M;i++)
    {
        cin>>L>>R;
        cout<<qmin(L,R)<<"\n";
    }


}