#include <fstream>
#include <climits>
using namespace std;
const int NMAX = 100000;
ifstream fin("rmq.in");
ofstream fout("rmq.out");
int minx;
int aint[4 * NMAX + 100];
void update(int node, int st, int dr, int poz, int val)
{
if(st == dr)
{
aint[node] = val;
return;
}
int med = ((st + dr) >> 1);
if(poz <= med)
update(2 * node, st, med, poz, val);
else
update(2 * node + 1, med + 1, dr, poz, val);
aint[node] = min(aint[2 * node], aint[2 * node + 1]);
}
void query(int node, int st, int dr, int start, int fin)
{
if(start <= st and dr <= fin)
{
minx = min(minx, aint[node]);
return;
}
int med = ((st + dr) >> 1);
if(start <= med)
query(2 * node, st, med, start, fin);
if(med < fin)
query(2 * node + 1, med + 1, dr, start, fin);
}
int main()
{
ios_base::sync_with_stdio(false);
fin.tie(NULL);
int n,m,i,x;
fin >> n >> m;
for(i = 1; i <= n; i++)
{
fin >> x;
update(1, 1, n, i, x);
}
while(m--)
{
fin >> i >> x;
minx = INT_MAX;
query(1, 1, n, i, x);
fout << minx << "\n";
}
return 0;
}