시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB14212211087.302%

문제

The countdown to the Olympic and Paralympic Games Tokyo 2020 continues until summer 2021. That aside, you are asked to count up the occurrences of the four integers 2, 0, 2, and 0 appearing consecutively in this order in given lists of integers.

입력

The input consists of multiple datasets, each in the following format.

n d1 … dn

Each of the datasets consists of two lines. The first line has an integer n (4 ≤ n ≤ 1000), which is the number of integers listed in the second line. The second line contains n integers d1, …, dn separated by spaces. Here, all of d1 to dn are between 0 and 9, inclusive.

The end of the input is indicated by a line containing a zero.

The number of datasets does not exceed 100.

출력

For each of the datasets, output one line containing the number of times the four integers 202, and 0 appear consecutively in this order in the list of integers in its second line. Overlapping occurrences are separately counted. “2 0 2 0 2 0 2 0”, for example, is said to have three occurrences, rather than two.

예제 입력 1

15
2 0 2 0 2 2 0 2 0 2 2 0 2 0 2
20
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
32
1 8 1 9 1 9 2 0 2 0 2 1 2 1 2 2 2 2 2 1 2 1 2 0 2 0 1 9 1 9 1 8
32
2 0 1 8 2 0 1 9 2 0 2 0 2 0 2 1 2 0 2 2 2 0 2 3 2 0 2 1 2 0 2 0
0

예제 출력 1

3
0
2
3