#include <iostream> #include <cstring> #include <cstdio> #include <queue> using namespace std; int n; #define DIM 100000 char buff[DIM]; int poz = DIM - 1; void Read(int &a) { #define adv() (++poz == DIM) ? cin.read(buff, DIM), poz=0 : 0 for(; !isdigit(buff[poz]); adv()); for(a = 0; isdigit(buff[poz]); a = a * 10 + buff[poz] - '0', adv()); } #define MAXN 500005 int P[MAXN]; int T[MAXN], added, Delta[MAXN]; bool Bad[MAXN]; #define zeros(a) (a&-a) void ins(int pos) { for(;pos<=n;pos+=zeros(pos)) T[pos]++; added++; } int query(int pos) { int sum = 0; for(;pos;pos-=zeros(pos)) sum += T[pos]; return sum - (added - sum); } void getDelta(int i) { memset(T, 0, sizeof(T)); added = 0; int inv = 0; for(int j=i+1; j<=n; j++) { Delta[j] = inv + query(P[j]); ins(P[j]); inv += (P[i] < P[j] ? 1 : -1); } memset(T, 0, sizeof(T)); added = 0; inv = 0; for(int j=i-1; j; j--) { Delta[j] = inv - query(P[j]); ins(P[j]); inv += (P[i] > P[j] ? 1 : -1); } } bool lss(int a1, int b1, int c1, int a2, int b2, int c2) { if(a1 != a2) return a1 < a2; if(b1 != b2) return b1 < b2; return c1 < c2; } int best = 100, c1 = -1, c2 = -1; int Compute(int i) { getDelta(i); for(int j=1; j<i; j++) { if(P[j] > P[i] && lss(Delta[j], j, i, best, c1, c2)) { best = Delta[j]; c1 = j; c2 = i; } } int b = 100, nj = -1; for(int j=i+1; j<=n; j++) { if(P[j] < P[i] && lss(Delta[j], i, j, best, c1, c2)) { best = Delta[j]; c1 = i; c2 = j; } if(P[j] < P[i] && b > Delta[j]) { b = Delta[j]; nj = j; } } return nj; } struct maimare { const bool operator() (int a, int b) { return P[a] < P[b]; } }; struct maimic { const bool operator() (int a, int b) { return P[a] > P[b]; } }; priority_queue<int, vector<int>, maimare> Max; priority_queue<int, vector<int>, maimic> Min; void Solve() { int minim = 1000000; for(int i=n; i>=1; i--) { if(P[i] < minim) { Bad[i] = 1; minim = P[i]; } } int i = 1; while(Bad[i]) i++; while(i <= n) { int nj = Compute(i); if(nj == -1) { while(Bad[i]) i++; } else i = nj; } int II = 5; for(int i=1; i<=n; i++) { Max.push(i); if(Max.size() >= II) Max.pop(); Min.push(i); if(Min.size() >= II) Min.pop(); } while(!Max.empty()) { Compute(Max.top()); Compute(Min.top()); Max.pop(); Min.pop(); } if(c1 == -1) { cout<<"Cool Array"; } else { cout<<c1<<" "<<c2; } } int main() { //freopen("debug.in", "r", stdin); Read(n); for(int i=1; i<=n; i++) Read(P[i]); Solve(); return 0; }