#include void chmax(int* a, int b) { if (*a < b) *a = b; } int main() { int i, N, m[200001], p[200001]; scanf("%d", &N); for (i = 1; i <= N; i++) { scanf("%d", &(m[i])); p[m[i]] = i; } int j, k, max[200001], len, num; for (i = 1; i <= N; i++) max[i] = m[i]; for (k = 1; k <= 5000; k++) { for (i = 1; i <= N; i++) { if (p[i] == 1) p[i] = 2; else if (p[i] == N) p[i] = N - 1; else if (max[p[i]-1] > max[p[i]+1]) p[i]--; else p[i]++; } for (i = 1; i <= N; i++) max[i] = 0; for (i = 1; i <= N; i++) chmax(&(max[p[i]]), i); for (i = 1, num = 0, len = 0; i <= N; i = j) { if (max[i] == 0) { j = i + 1; continue; } num++; for (j = i + 1; j <= N && max[j] != 0; j++); chmax(&len, j - i); } if (len == 2) break; } printf("%d %d\n", k, num); fflush(stdout); return 0; }