#include <cstdlib> #include <cstdio> #include <iostream> #include <cmath> #include <algorithm> #include <vector> #include <set> #include <map> #include <cstring> using namespace std; typedef long long LL; typedef unsigned long long ULL; #define SIZE(x) (int((x).size())) #define rep(i,l,r) for (int i=(l); i<=(r); i++) #define repd(i,r,l) for (int i=(r); i>=(l); i--) #define rept(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++) #ifndef ONLINE_JUDGE #define debug(x) { cerr<<#x<<" = "<<(x)<<endl; } #else #define debug(x) {} #endif #define maxn 1000010 struct event { int x, y1, y2, val; event() {} event(int x, int y1, int y2, int val): x(x), y1(y1), y2(y2), val(val) {} }; event e[maxn]; int a[maxn], up[maxn], down[maxn]; int cmp(const event &a, const event &b) { if (a.x!=b.x) return a.x<b.x; if (a.val!=b.val) return a.val<b.val; if (a.y1!=b.y1) return a.y1<b.y1; return a.y2<b.y2; } struct node { int left, right, mid, maxv, maxvi, tag; node() {} }; node t[2097153]; void build(int i, int l, int r) { t[i].left=l; t[i].right=r; t[i].mid=(l+r)/2; t[i].maxv=0; t[i].maxvi=l; t[i].tag=0; if (l==r) return; build(i*2,l,t[i].mid); build(i*2+1,t[i].mid+1,r); } void apply(int i, int val) { t[i].maxv+=val; t[i].tag+=val; } void spread(int i) { apply(i*2,t[i].tag); apply(i*2+1,t[i].tag); t[i].tag=0; } void update(int i) { if (t[i*2].maxv>=t[i*2+1].maxv) { t[i].maxv=t[i*2].maxv; t[i].maxvi=t[i*2].maxvi; } else { t[i].maxv=t[i*2+1].maxv; t[i].maxvi=t[i*2+1].maxvi; } } void serere(int i, int l, int r, int val) { if (l<=t[i].left && t[i].right<=r) { apply(i,val); return; } spread(i); if (l<=t[i].mid) serere(i*2,l,r,val); if (t[i].mid<r) serere(i*2+1,l,r,val); update(i); } int x1[maxn], x2[maxn]; void lemon() { int n; scanf("%d",&n); rep(i,1,n) scanf("%d",&a[i]); int flag=1; rep(i,1,n) if (a[i]!=i) flag=0; if (flag) { printf("Cool Array\n"); return; } int utop=0; rep(i,1,n) if (utop==0 || a[i]>a[up[utop]]) { utop++; up[utop]=i; } int dtop=0; rep(i,1,n) { while (dtop>0 && a[i]<a[down[dtop]]) dtop--; dtop++; down[dtop]=i; } rep(i,1,utop) x1[i]=a[up[i]]; rep(i,1,dtop) x2[i]=a[down[i]]; int all=0; rep(i,1,n) { int l1=lower_bound(x1+1,x1+utop+1,a[i])-x1; int r1=(upper_bound(up+1,up+utop+1,i)-up)-1; int l2=lower_bound(down+1,down+dtop+1,i)-down; int r2=(upper_bound(x2+1,x2+dtop+1,a[i])-x2)-1; if (l1<=r1 && l2<=r2) { all++; e[all]=event(l1,l2,r2,1); all++; e[all]=event(r1+1,l2,r2,-1); } } sort(e+1,e+all+1,cmp); build(1,1,n); int ans=0, ansup, ansdown; rep(i,1,all) { serere(1,e[i].y1,e[i].y2,e[i].val); if (t[1].maxv>ans) { ans=t[1].maxv; ansup=up[e[i].x]; ansdown=down[t[1].maxvi]; } } printf("%d %d\n",ansup,ansdown); } int main() { ios::sync_with_stdio(true); lemon(); return 0; }