#include using namespace std; #define ll long long #define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL) #define mp make_pair #define cps CLOCKS_PER_SEC #define mod (ll)1000000007 #define f first #define s second #define debug1(x) cout< #define pii pair #define pb push_back #define mxn 200005 ll tree[4*mxn],a[mxn]; void build(int i,int l,int r){ if(l==r){ tree[i]=a[l]; return; } int m=(l+r)>>1; build(i+i,l,m),build(i+i+1,m+1,r); tree[i]=max(tree[i+i],tree[i+i+1]); } ll query(int i,int l,int r,int x,int y){ if(l>r||l>y||r=x&&r<=y) return tree[i]; int m=(l+r)>>1; return max(query(i+i,l,m,x,y),query(i+i+1,m+1,r,x,y)); } int main(){ sp; ll n,n1,n2,k=0,mmax=0; cin>>n; int j; n1=(n*(n+1))/2; for(ll i=1; i>a[i]; mmax=max(a[i],mmax); } vector b; build(1,1,n); for(int k=0; k