#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; } vector P(N); rep(i,N) P[A[i]] = i; vector P1; rep(t,2){ vector maxG(N+2, -1); rep(i,N) maxG[P[i]+1] = max(maxG[i+1], i); rep(i,N){ int p = P[i]; if(maxG[p] > maxG[p+2]) P[i] = p-1; else P[i] = p+1; } if(t == 0) P1 = P; } vector has(N+1,-1); rep(i,N) has[P[i]] = P[i]; for(int i=1; i<=N; i++) if(has[i-1] != -1 && has[i] != -1) has[i] = has[i-1]; vector has1(N+3,-1); rep(i,N) has1[P1[i]] = P1[i]; int t1 = 1; rep(i,N) if(has1[i] != -1 && has1[i+1] != -1 && has1[i+2] != -1) t1 = 0; int blockcnt = 0; rep(i,N) if(has[i] != -1 && has[i+1] == -1) blockcnt++; vector has_freq(N); rep(i,N) if(has[i] != -1) has_freq[has[i]]++; int blockt = 0; rep(i,N) blockt = max(blockt, has_freq[i]); if(t1) blockt = 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;