cho.sh
NotesCho Mini
Loading...

Mischievous Frogs

Time limit

1s

Memory limit

128 MB

Problem

There are (N) rice plants in a straight line. During the night, several frogs entered the field from the left and left to the right. For each position, you know how many frogs stepped on it.

A frog chooses one positive jump interval (d), where (d le 6). If its first landing point is the (s)-th position from the left, then (1 le s le d). After that it lands only on positions (s+d, s+2d, s+3d, dots) while they are still inside the field. Each frog must land on at least two positions before leaving, so (s+d le N). It never changes direction or interval, and it never lands between rice plants.

Given the number of times each position was stepped on, find the minimum possible number of frogs and one corresponding route for each frog.

Input

The first line contains the number of rice-plant positions (N). ((2 le N le 200))

The second line contains, from left to right, the number of frogs that stepped on each position. Adjacent numbers are separated by one space.

The input is guaranteed to have a valid answer whose minimum number of frogs is at most 100.

Output

Print the minimum possible number (M) of frogs on the first line.

On each of the next (M) lines, print two integers (s) and (d): the first position stepped on by that frog, counted from the left, and its jump interval.

If more than one minimum construction exists, print any one of them.