406303: GYM102348 F The Number of Products
Description
You are given a sequence $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ integers.
You have to calculate three following values:
- the number of pairs of indices $$$(l, r)$$$ $$$(l \le r)$$$ such that $$$a_l \cdot a_{l + 1} \dots a_{r - 1} \cdot a_r$$$ is negative;
- the number of pairs of indices $$$(l, r)$$$ $$$(l \le r)$$$ such that $$$a_l \cdot a_{l + 1} \dots a_{r - 1} \cdot a_r$$$ is zero;
- the number of pairs of indices $$$(l, r)$$$ $$$(l \le r)$$$ such that $$$a_l \cdot a_{l + 1} \dots a_{r - 1} \cdot a_r$$$ is positive;
The first line contains one integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^{5})$$$ — the number of elements in the sequence.
The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ $$$(-10^{9} \le a_i \le 10^{9})$$$ — the elements of the sequence.
OutputPrint three integers — the number of subsegments with negative product, the number of subsegments with product equal to zero and the number of subsegments with positive product, respectively.
ExamplesInput5 5 -3 3 -1 0Output
6 5 4Input
10 4 0 -4 3 1 2 -4 3 0 3Output
12 32 11Input
5 -1 -2 -3 -4 -5Output
9 0 6Note
In the first example there are six subsegments having negative products: $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 2)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, $$$(4, 4)$$$, five subsegments having products equal to zero: $$$(1, 5)$$$, $$$(2, 5)$$$, $$$(3, 5)$$$, $$$(4, 5)$$$, $$$(5, 5)$$$, and four subsegments having positive products: $$$(1, 1)$$$, $$$(1, 4)$$$, $$$(2, 4)$$$, $$$(3, 3)$$$.