#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair<ll, ll>
#define sz(x) (int)((x).size())
#define all(a) (a).begin(), (a).end()
/* int f[maxn],nf[maxn],inv[maxn];
const int M=998244353;
void init(){
inv[1]=1; for (int i=2;i<maxn;i++) inv[i]=M-1ll*(M/i)*inv[M%i]%M;
f[0]=nf[0]=1; for (int i=1;i<maxn;i++) f[i]=1ll*f[i-1]*i%M,nf[i]=1ll*nf[i-1]*inv[i]%M;
}
int C(int x,int y){return 1ll*f[x]*nf[y]%M*nf[x-y]%M;}*/
const ll mod = 1e9+7;
ll n, k, m, mi, ma;
const ll N = 3e5;
ll st[N];
ll get(ll x, ll y, ll a, ll b, ll i){
//if(y < a || b < x) return mod;
if(x <= a && b <= y) return st[i];
ll v = mod;
if(!(y < a || (a + b)/2 < x)) v = get(x, y, a, (a + b)/2, 2*i);
if(!(y < (a + b)/2 + 1 || b < x)) v = min(v, get(x, y, (a + b)/2 + 1, b, 2*i + 1));
return v;
}
void update(ll x, ll a, ll b, ll i, ll d){
if(x < a || x > b) return;
if(a == b){
st[i] = d;
return;
}
if(x <= (a + b)/2) update(x, a, (a + b)/2, 2*i, d); else update(x, (a + b)/2 + 1, b, 2*i + 1, d);
st[i] = min(st[2*i], st[2*i + 1]);
return;
}
void solve(){
ifstream cin("rmq.in");
ofstream cout("rmq.out");
cin >> n >> k;
for(int i = 0; i<n; i++){
cin >> m;
update(i, 0, n - 1, 1, m);
}
for(int i = 0; i<k; i++){
ll x, y;
cin >> x >> y;
x--; y--;
cout << get(x, y, 0, n - 1, 1) << "\n";
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t=1;
// cin >> t;
while(t--) solve();
return 0;
}