Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/massiv-ishora-almashinishlari

Number of sign changes

Easy 1000 ms 64 MB 30%
Share

An array of $n$ integers is given. For how many pairs of adjacent elements does the sign change — one is positive and the other negative? ($0$ is neither positive nor negative.)

The array in cells with signs; adjacent pairs with a sign change are marked with an arc

Input

The first line contains a positive integer $n$.
The second line contains $n$ integers — the elements of the array.

Output

One integer — the number of sign changes.

Note

$1 \le n \le 1000$
the elements are from $-10^{6}$ to $10^{6}$

Examples

Input #1
7
3 -2 -5 4 0 -1 6
Output #1
3
Input #2
1
-4
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.