#include #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define all(x) x.begin(), x.end() using namespace std; using ll=long long; using ld=long double; using P=pair; #include using namespace atcoder; //using mint=static_modint<998244353>; using mint=static_modint<1000000007>; ll n,q; vector a; int main(){ cin>>n>>q; a.resize(n); rep(i,n)cin>>a[i]; priority_queue,greater

> pq; rep(i,n)pq.push({a[i],i}); vector pos(n); int cnt=0; while(!pq.empty()){ P p=pq.top();pq.pop(); pos[p.second]=cnt; cnt++; } rep(i,q){ int x,y;cin>>x>>y; x--;y--; cout<