#include <bits/stdc++.h>
using namespace std;
int aint[3 * 100002], n, m, a[100002], mx;
ifstream fin("rmq.in");
ofstream fout("rmq.out");
void Update(int nod, int x, int y, int D, int V)
{
if(x == y)
{
aint[nod] = V;
return;
}
int mij = (x + y) / 2;
if(D <= mij)
Update(2 * nod, x, mij, D, V);
else Update(2 * nod + 1, mij + 1, y, D, V);
aint[nod] = min(aint[2 * nod], aint[2 * nod + 1]);
}
int Query(int nod, int x, int y, int a, int b)
{
if(a <= x && y <= b)
return aint[nod];
int mij = (x + y) / 2;
if(b <= mij)
return Query(2 * nod, x, mij, a, b);
if(a > mij)
return Query(2 * nod + 1, mij + 1, y, a, b);
return min(Query(2 * nod, x, mij, a, mij), Query(2 * nod + 1, mij + 1, y, mij + 1, b));
}
int main()
{
int x, y;
fin >> n >> m;
for(int i = 1; i <= n; i++)
{
fin >> x;
Update(1, 1, n, i, x);
}
for(int i = 1; i <= m; i++)
{
fin >> x >> y;
fout << Query(1, 1, n, x, y) << "\n";
}
return 0;
}