#include <iostream> #include <iomanip> #include <algorithm> #include <vector> #include <string> #include <cmath> #include <memory.h> #include <sstream> #include <stack> #include <fstream> #include <cstdio> #include <unordered_map> #include <map> #include <list> #include <stdlib.h> #include <queue> #include <set> using namespace std; /* */ vector<vector<int> > tree; int a[500001]; vector<int> build(int i, int x1, int x2) { if (x1 > x2) return vector<int>(); while (tree.size() <= i) tree.push_back(vector<int>()); if (x1 == x2) { tree[i] = vector<int> (1); tree[i][0] = a[x1]; return tree[i]; } vector<int> d[2]; d[0] = build(i*2 + 1, x1, (x1+x2)/2); d[1] = build(i*2 + 2, (x1+x2)/2+1, x2); priority_queue<pair<int, int> > q; int in[2] = {0}; for (int j = 0; j < 2; j++) { if (d[j].size()) q.push(make_pair(-d[j][0], j)); } while (!q.empty()) { pair<int, int> cur = q.top(); q.pop(); tree[i].push_back(-cur.first); in[cur.second]++; if (in[cur.second] < d[cur.second].size()) { q.push(make_pair(-d[cur.second][in[cur.second]], cur.second)); } } return tree[i]; } int query(int i, int x1, int x2, int a, int b, int x) { if (x1 > x2) return 0; if (x1 > b || x2 < a) return 0; if (x1 >= a && x2 <= b) { return upper_bound(tree[i].begin(), tree[i].end(), x)- tree[i].begin(); } int r = query(i*2 + 1, x1, (x1+x2)/2, a,b,x); r += query(i*2 + 2, (x1+x2)/2+1, x2, a,b,x); return r; } int pin[500001]; int N; int after[500001]; int main() { scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%d", &a[i]); pin[a[i]] = i; } after[N-1] = N-1; for (int i = N-2; i >= 0; i--) { if (a[i] < a[after[i+1]]) { after[i] = i; } else { after[i] = after[i+1]; } } build(0,0,N-1); int best = 0; int bi, bj; bi = bj = -1; int last = 0; for (int i = 0; i < N; i++) { while (i < N && a[i] < last) i++; if (i == N) break; for (int x = last+1; x <= a[i]; x++) { int j; if (N > 200) j = max(bj, after[pin[x]]); else j = after[pin[x]]; if (j <= i) continue; int cnt = query(0, 0, N-1, i, j, a[i]) - query(0, 0, N-1, i, j, a[j]); if (cnt > best || (cnt == best && make_pair(i, j) < make_pair(bi, bj))) { best = cnt; bi = i; bj = j; } } last = a[i]; } if (best == 0) { cout<<"Cool Array"<<endl; } else cout<<bi+1<<" "<<bj+1<<endl; }