#include <cstdlib> #include <cctype> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include <string> #include <iostream> #include <sstream> #include <map> #include <set> #include <queue> #include <stack> #include <fstream> #include <numeric> #include <iomanip> #include <bitset> #include <list> #include <stdexcept> #include <functional> #include <utility> #include <ctime> using namespace std; typedef long long LL; #define rep(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++) int n; int p[500010]; int calc() { int tot = 0; for (int i=0; i<n; i++) { for (int j=i+1; j<n; j++) { if (p[j]<p[i]) { tot++; } } } return tot; } long long sum[2][500010]; int l[500010], r[500010]; void update1(int x) { for (;x<=n;x+=x&-x) sum[0][x]++; } int get1(int x) { int y = 0; for (;x;x-=x&-x) y += sum[0][x]; return y; } void update2(int x) { for (;x;x-=x&-x) sum[1][x]++; } int get2(int x) { int y = 0; for (;x<=n;x+=x&-x) y += sum[1][x]; return y; } int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); cin>>n; for (int i=0; i<n; i++) scanf("%d", p+i); for (int i=0; i<n; i++) { l[i] = get2(p[i]+1); update2(p[i]); } for (int i=n-1; i>=0; i--) { r[i] = get1(p[i]-1); update1(p[i]); } int m = -1; int u = 0; for (int i=0; i<n; i++) { if (l[i]+r[i]>m) { m = l[i]+r[i]; u = i; } } if (m==0) { cout<<"Cool Array"; return 0; } int best = -1; int v = u; for (int i=0; i<=n; i++) { sum[0][i] = sum[1][i] = 0; } for (int i=u-1; i>=0; i--) { int tot = get1(p[i]-1) - get2(p[i]+1); tot += get2(p[u]+1) - get1(p[u]-1); update1(p[i]); update2(p[i]); if (tot>best || tot==best) { v = i; best = tot; } } for (int i=0; i<=n; i++) { sum[0][i] = sum[1][i] = 0; } for (int i=u+1; i<n; i++) { int tot = get1(p[u]-1) - get2(p[u]+1); tot += get2(p[i]+1) - get1(p[i]-1); update1(p[i]); update2(p[i]); if (tot>best) { v = i; best = tot; } } cout<<min(u, v)+1<<" "<<max(u, v)+1<<endl; /* for (int i=0; i<n; i++) { int l = 0, r = 0; for (int j=0; j<i; j++) if (p[j]>p[i]) l++; for (int j=i+1; j<n; j++) if (p[j]<p[i]) r++; //cout<<i+1<<" "<<l<<" "<<r<<" "<<l+r<<endl; } best = calc(); int x = -1, y = -1; for (int i=0; i<n; i++) { for (int j=i+1; j<n; j++) { swap(p[i], p[j]); if (calc() < best) { best = calc(); x = i+1, y = j+1; } swap(p[i], p[j]); } } cout<<x<<" "<<y<<endl; */ return 0; }