#include #include #include using namespace std; using i64 = long long; using u64 = unsigned long long; using i32 = int; using u32 = unsigned int; #define rep(i,n) for(int i=0; i<(n); i++) int main() { int N; cin >> N; vector A(N); rep(i,N){ int a; cin >> a; A[i] = a-1; } if(N == 2){ cout << "1 0\n"; return 0; } vector P(N); rep(i,N) P[A[i]] = i; vector dir(N, -1); rep(t,2){ vector maxG(N+2, -1); rep(i,N) maxG[P[i]+1] = max(maxG[P[i]+1], i); rep(i,N){ int p = P[i]; if(maxG[p] > maxG[p+2]){ P[i]--; if(dir[p] == 1) dir[p] = 2; else dir[p] = 0; } else{ P[i]++; if(dir[p] == 0) dir[p] = 2; else dir[p] = 1; } } } int blockcnt = 1; vector sep = {0}; rep(i,N-1) if(dir[i] == 0 && dir[i+1] == 1){ blockcnt++; sep.push_back(i+1); } sep.push_back(N); // rep(i,N) cout << dir[i]; cout << endl; int blockt = 0; rep(i,sep.size()-1){ int l = sep[i], r = sep[i+1]; int m1 = l; while(m1 < r && dir[m1] == 1) m1++; int m2 = m1; while(m2 < r && dir[m2] == 2) m2++; blockt = max({m1-l, r-m2, (r-l+1)/2}) - 1; } cout << blockt << " " << blockcnt << "\n"; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;