497_B. Tennis Game
Petya 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 ≤ 105).

The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 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 si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.

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
```python
n = int(input())

line = input().split()
lst = []
for num in line:
    lst.append(int(num))

cnt1 = [0]
cnt2 = [0]
c1 = 0
c2 = 0

for num in lst:
    if num == 1:
        c1 += 1
        cnt1.append(c2)
    else:
        c2 += 1
        cnt2.append(c1)

w = lst[n - 1]
ans = []
c1 = len(cnt1)
c2 = len(cnt2)
for t in range(n, 0, -1):
    s1 = 0
    s2 = 0
    i1 = 0
    i2 = 0
    l = 1
    while i1 < c1 and i2 < c2:
        if i1 + t >= c1 and i2 + t >= c2:
            if l == 1 and l == w and i1 + 1 == c1 and s1 > s2:
                ans.append((s1, t))
            elif l == 2 and l == w and i2 + 1 == c2 and s2 > s1:
                ans.append((s2, t))
            break
        elif i2 + t >= c2:
            s1 += 1
            l = 1
            i1 += t
            i2 = cnt1[i1]
        elif i1 + t >= c1:
            s2 += 1
            l = 2
            i2 += t
            i1 = cnt2[i2]
        else:
            if cnt1[i1 + t] < i2 + t:
                s1 += 1
                l = 1
                i1 += t
                i2 = cnt1[i1]
            else:
                s2 += 1
                l = 2
                i2 += t
                i1 = cnt2[i2]

ans.sort()

print(int(len(ans)))
for line in ans:
    print(str(line[0]) + ' ' + str(line[1]))

```