#include <iotream>
using namespace std;
int main() {
int N;
int out_sh1, out_sh2;
cin >> N;
int* ary = new int[N];
while (1) {
for (int i = 0; i < N; i++)
cin >> ary[i];
int reverse_cnt = 0;
// -1 count
for (int i = 0; i < N; i++) {
if ((ary[(i + 1) % N] - ary[i] + N) % N == 1)
reverse_cnt++;
}
reverse_cnt = N - reverse_cnt - 1;
int reverse_flag = 0;
int reverse_end, reverse_start;
if (reverse_cnt == -1)
{
out_sh1 = 0;
reverse_start = 0;
reverse_end = 0;
out_sh2 = 0;
}
else if (reverse_cnt == N - 1) {
out_sh1 = N - (ary[N - 1] - 1);
reverse_start = 0;
reverse_end = N - 1;
out_sh2 = 0;
}
else {
int k = 0;
while (1) {
if ((ary[(k + 1) % N] - ary[k % N] + N) % N != 1)
reverse_flag = 1;
else
if (reverse_flag == 1)
{
reverse_end = (k - 1) % N;
break;
}
k++;
}
reverse_start = (reverse_end - reverse_cnt + N + 1) % N;
out_sh2 = N - reverse_start;
out_sh1 = ary[reverse_end] - 1;
reverse_start = 0;
reverse_end = reverse_cnt - 1;
}
cout << out_sh1 << endl;
cout << reverse_start+1 << " " << reverse_end << endl;
cout << out_sh2 << endl;
}
}