#CCBOTPBA0000016. Đổi dấu liên tiếp (Adjacent Sign Changes)

Đổi dấu liên tiếp (Adjacent Sign Changes)

Adjacent Sign Changes

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

Count adjacent pairs with opposite nonzero signs; pairs containing zero do not count. Avoid multiplying the two values.

Input

n followed by n integers.

Output

Number of adjacent pairs of opposite signs.

Subtasks

  • Subtask 1 (20%): n ≤ 20, |a_i| ≤ 100.

  • Subtask 2 (30%): n ≤ 1000, |a_i| ≤ 10^6.

  • Subtask 3 (50%): n ≤ 100000, |a_i| ≤ 10^6.

Examples

Example 1

Input:

5
1 -2 0 -4 5

Output:

2

Explanation: The pairs (1,-2) and (-4,5) change sign; pairs involving zero do not.

Example 2

Input:

0

Output:

0

Explanation: There is no adjacent pair.