#include #include #define MAXN 1000010 using namespace std; int a[MAXN],Min[MAXN],Max[MAXN],Q[MAXN],n,k; void get_min(){ int st=0,ed=0; Q[ed++]=1; Min[1]=a[1]; for(int i=2;i<=n;i++){ while(sta[Q[ed-1]])) ed--; Q[ed++]=i; while(st