#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int a[100010];
int n,m;
int d[100010][110];
void RMQ_init()
{
for (int i=1;i<=n;++i) d[i][0]=a[i];
for (int j=1;(1<<j)<=n;++j)
for (int 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()
{
freopen("faithful.in","r",stdin);
freopen("faithful.out","w",stdout);
cin>>n>>m;
for (int i=1;i<=n;++i)
scanf("%d",&a[i]);
RMQ_init();
for (int i=1;i<=m;++i)
{
int x,y;
cin>>x>>y;
int p=RMQ(x,y);
printf("%d\n",p);
}
return 0;
}