시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB29023019383.550%

문제

For the new infectious disease, COVID-99, numbers of new positive cases of PCR tests conducted in the city are reported daily. You are requested by the municipal public relations department to write a program that counts the number of the peaks so far of the positive cases.

Here, the number of peaks is the number of days on which the number of positive cases reported is more than both of the day before and the next day.

As the PCR tests started before the disease started spreading in the city, the number of positive cases is zero on the first day. The last reported day is not counted as a peak. No two consecutive days have the same number of positive cases.

Figure A-1: Numbers of positive cases of the last dataset in Sample Input. Red circles indicate the peaks.

입력

The input consists of multiple datasets. Each dataset is in the following format.

n
v1 ... vn

n is the number of days on which the numbers of positive cases are reported (3 ≤ n ≤ 1000). vi is the number of positive cases on the i-th day, an integer between zero and 1000, inclusive. Note that v1 is zero, and vivi+1 for 1 ≤ i < n, as stated above.

The end of the input is indicated by a line containing a zero. The input consists of at most 100 datasets.

출력

For each dataset, output the number of peaks in a line.

예제 입력 1

3
0 1000 0
5
0 1 2 0 1
3
0 1 2
7
0 1 0 1 8 7 6
11
0 4 3 7 6 10 7 8 4 6 10
0

예제 출력 1

1
1
0
2
4