/** * author: enot.1.10, Vladimir Smykalov (enot.1.10@gmail.com) * created: 19.09.2015 23:00:37 **/ #include <iostream> #include <cstdio> #include <cstdlib> #include <string> #include <cstring> #include <cmath> #include <algorithm> #include <vector> #include <set> #include <map> #include <ctime> #include <cassert> #include <queue> #define fs first #define sc second #define F first #define S second #define pb push_back #define mp make_pair #define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i) #define forit(it,v) for(typeof((v).begin()) it = v.begin() ; it != (v).end() ; ++it) #define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr) #define sz(a) ((int)(a).size()) #define all(a) (a).begin(),a.end() #define pw(x) (1LL<<(x)) using namespace std; typedef long long ll; typedef double dbl; typedef vector<int> vi; typedef pair<int, int> pi; const int inf = (int)1.01e9; const dbl eps = 1e-9; /* --- main part --- */ #define TASK "1" const int maxn = (int)1e6+ 10; int a[maxn]; int ad[2000222]; pair<int, int> ma[2000222]; vector<pair<pair<int, int>, int> > z[1000111]; void init(int pos, int l, int r) { ma[pos] = mp(0, -l); ad[pos] = 0; if (l == r) return; init(pos + pos, l, (l + r) / 2); init(pos + pos + 1, (l + r) / 2 + 1, r); } void add(int pos, int l, int r, int ll, int rr, int v) { ll = max(ll, l); rr = min(rr, r); if (ll > rr) return; if (l == ll && r == rr) { ma[pos].F += v; ad[pos] += v; return; } if (ad[pos] != 0) { ma[pos + pos].F += ad[pos]; ad[pos + pos] += ad[pos]; ma[pos + pos + 1].F += ad[pos]; ad[pos + pos + 1] += ad[pos]; ad[pos] = 0; } add(pos + pos, l, (l + r) / 2, ll, rr, v); add(pos + pos + 1, (l + r) / 2 + 1, r, ll, rr, v); ma[pos] = max(ma[pos + pos], ma[pos + pos + 1]); } inline bool Less(int x, int y) { return a[x] < a[y]; } int T[maxn]; int main() { #ifdef home assert(freopen(TASK".in", "r", stdin)); assert(freopen(TASK".out", "w", stdout)); #endif int n; scanf("%d", &n); forn(i, n) scanf("%d", &a[i]); forn(i, n) --a[i]; int ok = 1; forn(i, n - 1) if (a[i] > a[i + 1]) ok = false; if (ok) return 0 * printf("Cool Array\n"); int res = 0; int resi = 0, resj = 0; vi v1, v2; { int x = 0; v1.pb(x); while (a[x] < n - 1) { int y = x + 1; while (a[y] < a[x]) ++y; x = y; v1.pb(x); } } { int x = n - 1; v2.pb(x); while (a[x] > 0) { int y = x - 1; while (a[y] > a[x]) --y; x = y; v2.pb(x); } } reverse(all(v2)); forn(i, n) { int l1 = lower_bound(all(v1), i, Less) - v1.begin(); if (v1[l1] == i) continue; int r1 = lower_bound(all(v1), i) - v1.begin() - 1; assert(l1 <= r1); int l2 = lower_bound(all(v2), i) - v2.begin(); if (v2[l2] == i) continue; int r2 = lower_bound(all(v2), i, Less) - v2.begin() - 1; assert(l2 <= r2); z[l1].pb(mp(mp(l2, r2), 1)); z[r1 + 1].pb(mp(mp(l2, r2), -1)); // cout << l1 << " " << r1 << " " << l2 << " " << r2 << endl; // l1, r1, l2, r2 } /*for (int i = 0; i < n - 1; i++) if (a[i] > a[i + 1] && res == 0) { res = 1; resi = i + 1; resj = i + 2; } */ forn(i, sz(v1)) T[v1[i]] |= 1; forn(i, sz(v2)) T[v2[i]] |= 2; res = 1; resi = 0; while (T[resi] != 1) ++resi; resj = resi + 1; while (T[resj] != 2) ++resj; ++resi, ++resj; init(1, 0, v2.size() - 1); for (int i = 0; i < sz(v1); i++) { for (int j = 0; j < z[i].size(); j++) add(1, 0, v2.size() - 1, z[i][j].F.F, z[i][j].F.S, z[i][j].S); pair<int, int> e = ma[1]; int val = 1 + e.F; if (val == 1) continue; int x = v1[i]; int y = v2[-e.S]; if (val > res || (val == res && mp(resi, resj) > mp(x + 1, y + 1))) { res = val; resi = x + 1; resj = y + 1; } } if (res == 0) { printf("Cool Array\n"); } else { printf("%d %d\n", resi, resj); } #ifdef home eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC)); #endif return 0; }