#include<fstream>
#include<random>
#include<ctime>
using namespace std;
ifstream cin("rmq.in");
ofstream cout("rmq.out");
mt19937 rng(time(nullptr));
struct nod
{
int h,p,sz,best;
nod *c[2];
nod(int &a) : h(a),p(rng()),sz(1),best(a) {c[0] = c[1] = NULL;}
}*useless;
int size(nod *&treap){return treap ? treap->sz : 0;}
int ga(nod *&treap){return treap ? treap->best : (1 << 29);}
void split(nod *r,nod *&left,nod *&right,int x,int cheie = 0)
{
if(x < 0)
{
left = NULL;
right = r;
return;
}
if(!r) left = NULL,right = NULL;
else
{
cheie += size(r->c[0]);
if(cheie <= x) split(r->c[1],r->c[1],right,x,cheie + 1),left = r;
else split(r->c[0],left,r->c[0],x,cheie - size(r->c[0])),right = r;
r->sz = 1 + size(r->c[0]) + size(r->c[1]);
r->best = min(r->h,min(ga(r->c[0]),ga(r->c[1])));
}
}
void merge(nod *&r,nod *left,nod *right)
{
if(!left || !right) r = left ? left : right;
else
{
if(left->p > right->p) merge(left->c[1],left->c[1],right),r = left;
else merge(right->c[0],left,right->c[0]),r = right;
r->sz = 1 + size(r->c[0]) + size(r->c[1]);
r->best = min(r->h,min(ga(r->c[0]),ga(r->c[1])));
}
}
int main()
{
int n,a,b,q,c; nod *treap = nullptr; cin >> n >> q;
for(int i = 0 ; i < n ; i++) cin >> a,merge(treap,treap,new nod(a));
while(q--)
{
cin >> a >> b; a--,b--;
nod *u,*d,*t,*p;
split(treap,u,d,a - 1,0);
split(d,t,p,b - a,0); cout << t->best << '\n';
merge(treap,u,t); merge(treap,treap,p);
}
// afis(treap);
}