Head or Tail

No attempts yetTime limit1sMemory limit128 MB

Problem

John and Mary have been friends since nursery school. Ever since, they have shared a playful routine: every time they meet, they play Head or Tail by flipping a coin, and whoever wins gets to decide what they will do that day. Mary always chooses Head, and John always chooses Tail.

Now they are in college, but they are still truly good friends. Whenever they meet, they still play Head or Tail, and the winner decides which film to watch, which restaurant to have dinner at, and so on.

Yesterday Mary told John that she has kept a record of the result of every game they have played since nursery school. This came as a surprise to John! Since John studies Computer Science, he saw it as a good chance to show off his programming skills by writing a program that counts how many times each of them has won over the years.

Given the record of every game, determine how many games Mary won and how many games John won.

Input

The input contains several test cases. The first line of each test case contains a single integer $N$, the number of games played ($1 \le N \le 10000$). The next line contains $N$ integers $R_i$ separated by spaces, describing the results. If $R_i = 0$, Mary won the $i$-th game; if $R_i = 1$, John won the $i$-th game ($1 \le i \le N$). The end of the input is indicated by $N = 0$, which must not be processed.

Output

For each test case, output a single line containing the sentence Mary won X times and John won Y times, where $X \ge 0$ is the number of games Mary won and $Y \ge 0$ is the number of games John won.