Counting problem (4)

Given a sequence of n integer numbers x₁…x_(n), count how many i’s, with
1 ≤ i ≤ n, follow the property

|{j : 1 ≤ j < i ∧ x_(j) < x_(i)}| = |{j : 1 ≤ j < i ∧ x_(j) > x_(i)}| .

Input

The input consists of several cases. Each case begins with n, followed
by the n integer numbers x₁…x_(n). Assume 0 ≤ n ≤ 10⁵.

Output

For each case, print the number of indices i that fulfill the condition
above.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T11:19:42.649Z

© Jutge.org, 2006–2026.
https://jutge.org
