#CCBCHBAHAI0000020. Đếm số lần đổi dấu (Count Sign Changes)
Đếm số lần đổi dấu (Count Sign Changes)
Đếm số lần đổi dấu (Count Sign Changes)
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
Given an integer sequence .
For each with , the adjacent pair is a sign change exactly when one value is negative and the other is positive:
If or , that pair is not counted as a sign change.
Count the indices satisfying the condition.
Input
The first line contains integer . The second line contains space-separated integers .
Output
Print one integer: the number of sign changes between adjacent elements.
Subtasks
Subtask 1 (100 points): ; .
Example
Input
6
-3 2 0 -5 4 -1
Output
3
Explanation
The pairs , , and change sign. Pairs containing are not counted.