#CCBCHBAHAI0000067. Đếm số lần đổi dấu giữa hai phần tử kề (Count Sign Changes Between Adjacent Elements)

    ID: 985 Loại: Thông thường 2000ms 256MiB Tried: 0 Đã chấp nhận: 0 Độ khó: 1 Đăng bởi: Nhãn>Programming language basicsStatic arraysIteration techniquesImplementation techniquesInteger arithmetic

Đếm số lần đổi dấu giữa hai phần tử kề (Count Sign Changes Between Adjacent Elements)

Count Sign Changes Between Adjacent Elements (Đếm số lần đổi dấu giữa hai phần tử kề)

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem

Given a0,a1,…,an−1a_0,a_1,\ldots,a_{n-1}, an adjacent pair (ai−1,ai)(a_{i-1},a_i) for 1≤i<n1\le i<n is a sign change exactly when one value is negative and the other is positive:

(ai−1<0<ai)∨(ai<0<ai−1).(a_{i-1}<0<a_i)\lor(a_i<0<a_{i-1}).

Equivalently, ai−1ai<0a_{i-1}a_i<0. If either value is zero, the pair is not counted. Count all such adjacent sign changes.

Input

The first line contains nn. The second line contains nn integers aia_i.

Output

Print the number of adjacent sign changes.

Subtask

Subtask 1 (20 points): 1≤n≤101\le n\le10, ∣ai∣≤103|a_i|\le10^3.

Subtask 2 (30 points): 1≤n≤50001\le n\le5000, ∣ai∣≤106|a_i|\le10^6.

Subtask 3 (50 points): 1≤n≤2⋅1051\le n\le2\cdot10^5, ∣ai∣≤109|a_i|\le10^9.

Example

Input

8
-2 5 0 -3 4 -1 -1 6

Output

4

Explanation

The sample follows the mathematical definition above.