#include <algorithm> #include <cstdio> #include <cstring> #include <set> #include <vector> #define FOR(i,a,b) for(i=a; i<=b; i++) #define FOR2(i,n) FOR(i,0,n-1) #define TFOR(i,a,b) for(i=a; i>=b; i--) #define f first #define s second #define all(x) x.begin(),x.end() #define MAXN 500005 #define MAXT 1050000 using namespace std; typedef pair < int , int > pii; typedef pair < pii , pii > pii4; int read(){ int res(0),sign(1); char c; while(1){ c = getchar(); if('0' <= c && c <= '9') { res = c - '0'; break; } else if(c == '-') { sign = -1; break; } } while(1){ c = getchar(); if('0' <= c && c <= '9') res = res*10 + c - '0'; else break; } return res * sign; } class segment { public: int f,s,t; segment() { f = s = t = 0; } }ST[MAXT]; set < pii > st; vector < pii4 > V; pii P[MAXN]; int N,S1,S2; int A[MAXN] , B[MAXN] , C[MAXN]; void add( int x1 , int y1 , int x2 , int y2 ) { if( x1 == x2 && y1 == y2 && B[x1] == C[y1] ) return; // printf("x1 = %d x2 = %d y1 = %d y2 = %d\n" , x1 , x2 , y1 , y2 ); V.push_back( make_pair( make_pair( y1 , 1 ) , make_pair( x1 , x2 ) ) ); V.push_back( make_pair( make_pair( y2 + 1 , -1 ) , make_pair( x1 , x2 ) ) ); } void upd( int pos , int x ) { ST[pos].f += x; ST[pos].s += x; } void init( int pos , int s , int e ) { ST[pos].f = ST[pos].s = 0; if( s == e ) return void( ST[pos].t = s ); int m = ( s + e ) >> 1; int sol = pos << 1; int sag = sol | 1; ST[pos].f = ST[pos].s = 0; init( sol,s,m ); init( sag,m+1,e ); ST[pos].t = ST[sol].t; } void update( int pos , int s , int e , int a , int b , int x ) { if( a > e || b < s ) return; if( a <= s && e <= b ) return upd( pos,x ); int m = ( s + e ) >> 1; int sol = pos << 1; int sag = sol | 1; if( ST[pos].s ) { upd( sol,ST[pos].s ); upd( sag,ST[pos].s ); ST[pos].s = 0; } update( sol,s,m,a,b,x ); update( sag,m+1,e,a,b,x ); if( ST[sol].f >= ST[sag].f ) { ST[pos].f = ST[sol].f; ST[pos].t = ST[sol].t; } else { ST[pos].f = ST[sag].f; ST[pos].t = ST[sag].t; } } int main() { int i; N = read(); FOR(i,1,N) A[i] = read(); int a,b,maxi(0),mini(MAXN) , last; FOR(i,1,N) if( A[i] > maxi ) { maxi = A[i]; last = ++S1; B[ S1 ] = i; P[i] = make_pair( S1 , S1 ); st.insert( make_pair( A[i] , S1 ) ); } else P[i] = make_pair( st.upper_bound( make_pair( A[i] , 0 ) )->s , last ); st.clear(); TFOR(i,N,1) { if( A[i] < mini ) { mini = A[i]; last = ++S2; C[ S2 ] = i; add( P[i].f , S2 , P[i].s , S2 ); st.insert( make_pair( -A[i] , S2 ) ); } else add( P[i].f , st.upper_bound( make_pair( -A[i] , 0 ) )->s , P[i].s , last ); } sort( all(V) ); vector < pii4 > :: iterator it; init( 1,1,S1 ); vector < pii > res; maxi = 0; for( it = V.begin(); it != V.end(); ++it ) { update( 1,1,S1 , it->s.f,it->s.s , it->f.s ); if( it->f.s == -1 ) continue; if( ST[1].f > maxi ) { maxi = ST[1].f; res.clear(); } if( ST[1].f == maxi ) res.push_back( make_pair( B[ ST[1].t ] , C[ it->f.f ] ) ); } if( res.empty() ) printf("Cool Array\n"); else { sort( all(res) ); printf("%d %d\n" , res[0].f , res[0].s ); } return 0; }