Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years.
×

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

D. Tennis Game

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputPetya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores *t* points, he wins the set; then the next set starts and scores of both players are being set to 0. As soon as one of the players wins the total of *s* sets, he wins the match and the match is over. Here *s* and *t* are some positive integer numbers.

To spice it up, Petya and Gena choose new numbers *s* and *t* before every match. Besides, for the sake of history they keep a record of each match: that is, for each serve they write down the winner. Serve winners are recorded in the chronological order. In a record the set is over as soon as one of the players scores *t* points and the match is over as soon as one of the players wins *s* sets.

Petya and Gena have found a record of an old match. Unfortunately, the sequence of serves in the record isn't divided into sets and numbers *s* and *t* for the given match are also lost. The players now wonder what values of *s* and *t* might be. Can you determine all the possible options?

Input

The first line contains a single integer *n* — the length of the sequence of games (1 ≤ *n* ≤ 10^{5}).

The second line contains *n* space-separated integers *a*_{i}. If *a*_{i} = 1, then the *i*-th serve was won by Petya, if *a*_{i} = 2, then the *i*-th serve was won by Gena.

It is not guaranteed that at least one option for numbers *s* and *t* corresponds to the given record.

Output

In the first line print a single number *k* — the number of options for numbers *s* and *t*.

In each of the following *k* lines print two integers *s*_{i} and *t*_{i} — the option for numbers *s* and *t*. Print the options in the order of increasing *s*_{i}, and for equal *s*_{i} — in the order of increasing *t*_{i}.

Examples

Input

5

1 2 1 2 1

Output

2

1 3

3 1

Input

4

1 1 1 1

Output

3

1 4

2 2

4 1

Input

4

1 2 1 2

Output

0

Input

8

2 1 2 1 1 1 1 1

Output

3

1 6

2 3

6 1

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Feb/24/2020 12:32:26 (f1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|