#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("rmq.in");
ofstream fout("rmq.out");
int n, m;
int v[400100];
void update(int nod, int st, int dr, int pos, int value) {
if (st == pos && pos == dr) {
v[nod] = value;
return;
}
int mij = (st + dr) / 2;
if (pos <= mij)
update(2 * nod, st, mij, pos, value);
else
update(2 * nod + 1, mij + 1, dr, pos, value);
v[nod] = min(v[2 * nod], v[2 * nod + 1]);
}
int ask(int nod, int st, int dr, int a, int b) {
if (a <= st && dr <= b)
return v[nod];
int mij = (st + dr) / 2;
int sol = 2000000000;
if (a <= mij)
sol = min(sol, ask(2 * nod, st, mij, a, b));
if (b > mij)
sol = min(sol, ask(2 * nod + 1, mij + 1, dr, a, b));
return sol;
}
int main() {
fin >> n >> m;
for (int i = 1; i <= n; i++) {
int nr;
fin >> nr;
update(1, 1, n, i, nr);
}
for (int i = 1; i <= m; i++) {
int a, b;
fin >> a >> b;
fout << ask(1, 1, n, a, b) << '\n';
}
return 0;
}