#include <cstdio> #include <vector> #include <algorithm> using namespace std; struct Node { int val; int c[2]; Node() { val = 0, c[0] = c[1] = 0; } }; int head[500013]; Node nodes[10000013]; int on = 1; int make() { return on++; } inline void add(int& curI, int otherI, int L, int R, int a) { if (!curI) curI = make(); Node& cur = nodes[curI]; Node other = nodes[otherI]; if (L==R) cur.val = other.val+1; else { if (a<=(L+R)/2) { cur.c[0] = make(); add(cur.c[0],other.c[0],L,(L+R)/2,a); cur.c[1] = other.c[1]; } else { cur.c[1] = make(); add(cur.c[1],other.c[1],(L+R)/2+1,R,a); cur.c[0] = other.c[0]; } for (int d=0;d<2;d++) if (cur.c[d]) cur.val+=nodes[cur.c[d]].val; } } inline int query(int curI, int curI2, int L, int R, int a, int b) { if (!curI) return 0; Node cur = nodes[curI]; Node cur2 = nodes[curI2]; if (b<L || R<a) return 0; if (a<=L && R<=b) return cur.val-cur2.val; return query(cur.c[0],cur2.c[0],L,(L+R)/2,a,b)+query(cur.c[1],cur2.c[1],(L+R)/2+1,R,a,b); } int N; int p[500013]; int best[500013]; vector<int> upper; vector<int> lower; inline int check(int i, int j) { int res = query(head[j],head[i-1],1,N,p[j],p[i]); return (res-1)*2; } inline void go(int l, int r, int low, int high) { if (l>r) return; int mid = (l+r)/2; int cur = -1; int which = 0; for (int i=low;i<=high;i++) { int res = check(upper[mid],lower[i]); if (res>cur) { cur = res; which = i; } } best[upper[mid]] = lower[which]; go(l,mid-1,low,which); go(mid+1,r,which,high); } inline void solve() { upper.push_back(1); lower.push_back(1); for (int i=2;i<=N;i++) { if (p[i]>p[upper.back()]) upper.push_back(i); while (lower.size()>0 && p[i]<p[lower.back()]) lower.pop_back(); lower.push_back(i); } go(0,upper.size()-1,0,lower.size()-1); } int readint() { char c; while ((c=getchar_unlocked())<'0'); int res = c-'0'; while ((c=getchar_unlocked())>='0') res = res*10+c-'0'; return res; } int main() { N = readint(); for (int i=1;i<=N;i++) p[i] = readint(); for (int i=1;i<=N;i++) { add(head[i],head[i-1],1,N,p[i]); } int found = 0; for (int i=1;i<=N;i++) if (p[i]!=i) found = 1; if (!found) return printf("Cool Array\n"), 0; solve(); int ans = 0; int which = 0; for (int i=1;i<=N;i++) if (best[i]) { int res = check(i,best[i]); if (res>ans) { ans = res; which = i; } } printf("%d %d\n",which,best[which]); return 0; }