#include using namespace std; #define ll long long #define rep(i,n) for(int i=0;i> N; assert(2<=N&&N<=2e5); set num; vector a(N+2,0); vector b(N+2,0); rep(i,N){ cin >> a[i+1]; assert(1<=a[i+1]&&a[i+1]<=N); num.insert(a[i+1]); } assert(num.size()==N); if(N==2){ cout << 0 << " " << 1 << endl; return 0; } rep(i,N){ if(a[i]>a[i+2]) chmax(b[i],a[i+1]); else chmax(b[i+2],a[i+1]); } ll tim = 0,cnt = 0; ll l = 0,r = 0,om = 0,em = 0,oi = 0,ei = 0; rep(i,N+2){ if(b[i]==0){ if(l!=0){ ll m1 = min(oi,ei),m2 = max(oi,ei); ll tmp = 0; ll lw = m1-l,rw = r-m2,ct = m2-m1-1; if(ct!=0&&lw==0) lw++; if(ct!=0&&rw==0) rw++; tmp = max(lw,rw) + ct/2; cnt++; chmax(tim,tmp+1); } l = 0,r = 0,om = 0,em = 0; } else{ if(l==0) l = i; r = i; if(i%2==0&&b[i]>em){ em = b[i]; ei = i; } if(i%2==1&&b[i]>om){ om = b[i]; oi = i; } } } cout << tim << " " << cnt << endl; }