#include <cstdio>#define min(a, b) ((a)<(b)?(a):(b))int f[20][100010], lg[100010];inline int query(int l, int R) { int len = lg[R-l+1], r = R-(1<<len)+1; return min(f[len][l], f[len][r]);}int main() { int n, Q; scanf("%d%d", &n, &Q); for(int i = 1; i <= n; i ++ ) scanf("%d", &f[0][i]); for(int i = 2; i <= n; i ++ ) lg[i] = lg[i>>1]+1; for(int i = 1; i <= 16; i ++ ) for(int j = 1; j <= n; j ++ ) { f[i][j] = min(f[i-1][j], f[i-1][j+(1<<(i-1))]); } int l, r; scanf("%d%d", &l, &r); printf("%d", query(l, r)); while(Q -- ) { scanf("%d%d", &l, &r); printf(" %d", query(l, r)); }}