#include <bits/stdc++.h> using namespace std; #define X first #define Y second #define INPUT freopen("world.inp","r",stdin) #define OUTPUT freopen("world.out","w",stdout) #define FOR(i,l,r) for(auto i=l;i<=r;i++) #define REP(i,l,r) for(auto i=l;i<r;i++) #define FORD(i,l,r) for(auto i=l;i>=r;i--) #define REPD(i,l,r) for(auto i=l;i>r;i--) #define ENDL printf("\n") #define debug 1 typedef long long ll; typedef pair<int,int> ii; const int inf=1e9; const int MOD=1e9+7; const int N=5e5+10; int n,a[N],laz[N<<2],s[N],g[2][N]; ii ra[N]; vector <ii> dem[N]; vector <int> out[N]; struct info{ int v,pos; info(int _v=0,int _pos=0){ v=_v;pos=_pos; } }b[N<<2]; bool comp(info a,info b){ return (a.v==b.v)?(a.pos<b.pos):(a.v>b.v); } bool operator <(ii a,ii b){ return (a.X==b.X)?a.Y<b.Y:a.X<b.X; } void lazyupdate(int node,int L,int R){ b[node].v+=laz[node]; if (L<R){ laz[node*2]+=laz[node]; laz[node*2+1]+=laz[node]; } laz[node]=0; } void update(int node,int L,int R,int l,int r,int v){ lazyupdate(node,L,R); if (L>r||R<l) return; if (l<=L&&R<=r){ laz[node]+=v; lazyupdate(node,L,R); return; } update(node*2,L,(L+R)/2,l,r,v); update(node*2+1,(L+R)/2+1,R,l,r,v); b[node]=min(b[node*2],b[node*2+1],comp); } void prepare(){ scanf("%d",&n); FOR(i,1,n) scanf("%d",a+i); } void build(int node,int L,int R){ if (L==R){ b[node]=info(0,s[L]); return; } build(node*2,L,(L+R)/2); build(node*2+1,(L+R)/2+1,R); b[node]=min(b[node*2],b[node*2+1],comp); } void solve(){ ///check cool array bool cool=1; FOR(i,2,n) if (a[i]<a[i-1]) cool=0; if (cool){ printf("Cool Array"); return; } ///find special position int mi=inf,top=0; FORD(i,n,1) { if (a[i]<mi) g[1][i]=1; mi=min(mi,a[i]); } FOR(i,1,n) if (g[1][i]) s[++top]=i; s[++top]=n+1; int ma=-inf; FOR(i,1,n){ if (a[i]>ma) g[0][i]=1; ma=max(ma,a[i]); int L=1,R=top; while (L<=R){ int M=(L+R)/2; if (a[i]>=a[s[M]]) L=M+1; else R=M-1; } out[s[L]].push_back(i); // printf("%d ",s[L]); } // ENDL; top=0; FOR(i,1,n) if (g[0][i]) s[++top]=i; for(int i=1,j=0;i<=n;i++){ while (j<top&&s[j+1]<=i) j++; int L=1,R=top; while (L<=R){ int M=(L+R)/2; if (a[i]>a[s[M]]) L=M+1; else R=M-1; } ra[i]=ii(L,j); } // FOR(i,1,n) printf("%d ",g[0][i]);ENDL; // FOR(i,1,n) printf("%d ",g[1][i]);ENDL; // FOR(i,1,top) printf("%d ",s[i]);ENDL; // FOR(i,1,n) printf("%d %d\n",ra[i].X,ra[i].Y); // build(1,1,top); int ans=-inf; ii acur; FOR(i,1,n){ update(1,1,top,ra[i].X,ra[i].Y,1); for(auto j:out[i]) update(1,1,top,ra[j].X,ra[j].Y,-1); // printf("%d %d %d\n",i,b[1].pos,b[1].v); if (g[1][i]){ ii cur=ii(b[1].pos,i); if (b[1].v>ans||(b[1].v==ans&&cur<acur)) acur=cur,ans=b[1].v; } } printf("%d %d",acur.X,acur.Y); } int main(){ prepare(); solve(); }