cho.sh
Notes
Loading...

Lock

Time limit

1s

Memory limit

128 MB

Problem

A lock consists of N cells arranged in one row. Initially, cells 1 through N contain the numbers 1, 2, ..., N in that order.

To lock it, exactly three operations are performed in this order.

  1. Shift the row left by k cells. Numbers that leave the left end reappear at the right end in the same order. This is called a k-left shift, where 1 <= k < N.
  2. Reverse the current numbers from cell p through cell q. This is called a (p,q)-interval reversal, where p < q.
  3. Shift the row left by k cells again, also with 1 <= k < N.

You are given the final locked state. Find values for the three operations that can produce it. If several answers are possible, output any one of them.

Input

The first line contains the number of cells N. The value of N is between 10 and 500, inclusive.

The second line contains N integers, separated by spaces, giving the numbers in cells 1 through N after the lock has been locked.

Output

On the first line, output k for the first k-left shift.

On the second line, output p and q for the (p,q)-interval reversal, separated by a space.

On the third line, output k for the final k-left shift.

If there are multiple valid answers, output any one of them.