#include <bits/stdc++.h>
using namespace std;
ifstream f("rmq.in");
ofstream g("rmq.out");
int n, t, AI[300005], minim, a, b, val;
void update(int nod, int st, int dr, int indice, int val)
{
if (st == dr) {
AI[nod] = val;
return;
}
int mij = (st + dr) / 2;
if (indice <= mij) {
update(2 * nod, st, mij, indice, val);
}
else {
update(2 * nod | 1, mij + 1, dr, indice, val);
}
AI[nod] = min(AI[2 * nod], AI[2 * nod | 1]);
}
void query(int nod, int st, int dr, int a, int b)
{
if (a <= st && dr <= b) {
minim = min(minim, AI[nod]);
return;
}
int mij = (st + dr) / 2;
if (a <= mij) {
query(2 * nod, st, mij, a, b);
}
if (b > mij) {
query(2 * nod | 1, mij + 1, dr, a, b);
}
}
int main() {
f >> n >> t;
for (int i = 1; i <= n; ++i) {
f >> val;
update(1, 1, n, i, val);
}
while (t--) {
f >> a >> b;
minim = 2e9;
query(1, 1, n, a, b);
g << minim << '\n';
}
return 0;
}