#include<bits/stdc++.h> using namespace std; #define int long long const int N=500010; int a[N]; int Log[N]; int stmax[N][22],stmin[N][22]; void pre (){ Log[1]=0; Log[2]=1; for(int i=3;i<=N;i++){ Log[i]=Log[i/2]+1; } } signed main(){ ios::sync_with_stdio(0); cin.tie(0); pre(); int n; cin>...