import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class LaurenAndInversions { static int n; static int a[],pos[]; static int maxCnt[],maxVal[],lazy[]; static boolean inStructure[]; public static void main(String args[]) { InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); n = in.nextInt(); a = new int[n + 1]; for(int i=1;i<=n;i++) a[i] = in.nextInt(); pos = new int[n + 1]; for(int i=1;i<=n;++i) pos[a[i]] = i; maxCnt = new int[4 * n]; maxVal = new int[4 * n]; lazy = new int[4 * n]; inStructure = new boolean[n + 1]; int X = -1,Y = -1; int change = 0; int prev = n + 1; for(int i=n;i>1;i--){ if(pos[i] < prev){ for(int j=prev-1;j>=pos[i];j--){ addInStructure(1,n,0,a[j]); if(a[j] != 1) update(1,n,0,1,a[j]-1,1); } int ans[] = findMax(1,n,0,1,i-1); //System.out.println(i + " " + ans[0] + " " + ans[1]); int val = ans[0]; int cnt = ans[1]; if(inStructure[val]){ cnt = 2 * cnt - 1; if(cnt > change){ X = pos[i]; Y = pos[val]; change = cnt; } else if(cnt == change && (pos[i] < X || (pos[i] == X && pos[val] < Y))){ X = pos[i]; Y = pos[val]; } } prev = pos[i]; } update(1,n,0,1,i-1,-1); } if(X == -1) w.println("Cool Array"); else w.println(X + " " + Y); w.close(); } static void update(int s,int e,int c,int l,int r,int fk){ if(s == l && e == r){ maxCnt[c] += fk; lazy[c] += fk; } else{ propogate(c); int m = (s + e) >> 1; if(l <= m && r <= m) update(s,m,2*c+1,l,r,fk); else if(l > m && r > m) update(m+1,e,2*c+2,l,r,fk); else{ update(s,m,2*c+1,l,m,fk); update(m+1,e,2*c+2,m+1,r,fk); } merge(c); } } static void propogate(int c){ maxCnt[2*c + 1] += lazy[c]; maxCnt[2*c + 2] += lazy[c]; lazy[2*c + 1] += lazy[c]; lazy[2*c + 2] += lazy[c]; lazy[c] = 0; } static void merge(int c){ int ans = -1; if(!inStructure[maxVal[2*c + 1]]) ans = 2; else if(!inStructure[maxVal[2*c + 2]]) ans = 1; else if(maxCnt[2*c + 1] > maxCnt[2*c + 2]) ans = 1; else if(maxCnt[2*c + 2] > maxCnt[2*c + 1]) ans = 2; else if(pos[maxVal[2*c + 1]] < pos[maxVal[2*c + 2]]) ans = 1; else ans = 2; maxVal[c] = maxVal[2*c + ans]; maxCnt[c] = maxCnt[2*c + ans]; } static void addInStructure(int s,int e,int c,int x){ if(s == e){ if(s != x) System.out.println("WA"); maxVal[c] = x; maxCnt[c] = 0; inStructure[s] = true; return; } propogate(c); int m = (s + e) >> 1; if(x <= m) addInStructure(s,m,2*c+1,x); else addInStructure(m+1,e,2*c+2,x); merge(c); } static int[] findMax(int s,int e,int c,int l,int r){ //System.out.println(s + " " + e + " " + c + " " + l + " " + r + " " + maxVal[c] + " " + maxCnt[c]); if(s == l && e == r) return new int[]{maxVal[c],maxCnt[c]}; propogate(c); int m = (s + e) >> 1; if(r <= m) return findMax(s,m,2*c+1,l,r); if(l > m) return findMax(m+1,e,2*c+2,l,r); return merge(findMax(s,m,2*c+1,l,m) , findMax(m+1,e,2*c+2,m+1,r)); } static int[] merge(int[] a,int[] b){ if(!inStructure[a[0]]) return b; if(!inStructure[b[0]]) return a; if(a[1] > b[1]) return a; if(b[1] > a[1]) return b; if(pos[a[0]] < pos[b[0]]) return a; return b; } static class InputReader { private InputStream stream; private byte[] buf = new byte[8192]; private int curChar; private int snumChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int snext() { if (snumChars == -1) throw new InputMismatchException(); if (curChar >= snumChars) { curChar = 0; try { snumChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (snumChars <= 0) return -1; } return buf[curChar++]; } public int nextInt() { int c = snext(); while (isSpaceChar(c)) c = snext(); int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = snext(); } while (!isSpaceChar(c)); return res; } public boolean isSpaceChar(int c) { if (filter != null) return filter.isSpaceChar(c); return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } }