#include using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; template using V=vector; template using VV=V>; //B(n,V(n)) int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n,q; cin>>n>>q; V A(n); set s; rep(i,n){ cin>>A[i]; s.insert(A[i]); } map m; int now=0; for(auto x:s) m[x]=now++; while(q--){ int x,y; cin>>x>>y; x--,y--; cout<