cho.sh
Notes
Loading...

Bus Routes

Time limit

2s

Memory limit

128 MB

Problem

You arrive at a bus stop at 9:00 AM and stay there until 9:59 AM. During that hour, buses from several routes stop there, and you record the minute when each bus arrives.

For one route, buses arrive at a fixed minute interval starting from that route's first observed arrival. The observed times are integers from 0 to 59, where 0 means exactly 9:00 AM. Every route appears at least twice during the observed hour.

Different routes may share the same first arrival time, the same interval, or even the same complete schedule. If buses from multiple routes arrive at the same minute, that minute is recorded once for each arriving bus. Even two routes with identical first arrival time and interval are counted as separate routes.

Given the multiset of recorded arrival minutes, find route schedules that could have produced the record. Among all possible explanations, output one using the minimum number of routes. The number of routes in an optimal answer does not exceed 25.

Input

The first line contains the number of recorded arrivals n. (2 <= n <= 300)

The next values are the n arrival times. Each time is an integer from 0 to 59 and represents the number of minutes after 9:00 AM. The values may be separated by spaces or line breaks.

Output

Print the minimum number of routes X on the first line.

Then print X lines. Each line must contain the first arrival minute and the interval of one route, separated by a space. If there are multiple optimal answers, print any one of them. The routes may be printed in any order.

Hint

The following schedule illustration shows three routes by their arrival minutes.

0 13    ← 0 . . 13 . . 26 . . . 39 . . 52 . (5 arrivals)3 12    ← . 3 . . 15 . . 27 . . 39 . 51 . . (5 arrivals)5 8     ← . . 5 13 . 21 . . 29 37 . 45 . . 53 (7 arrivals)
0 13    ← 0 . . 13 . . 26 . . . 39 . . 52 . (5 arrivals)3 12    ← . 3 . . 15 . . 27 . . 39 . 51 . . (5 arrivals)5 8     ← . . 5 13 . 21 . . 29 37 . 45 . . 53 (7 arrivals)