【cf585-div2: B】 The Number of Products(dp/推导)

题目:


You are given a sequence ?1,?2,…,??a1,a2,…,an consisting of ?n non-zero integers (i.e. ??≠0ai≠0). 

You have to calculate two following values:

  1. the number of pairs of indices (?,?)(l,r) (?≤?)(l≤r) such that ??⋅??+1…??−1⋅??al⋅al+1…ar−1⋅ar is negative; 
  2. the number of pairs of indices (?,?)(l,r) (?≤?)(l≤r) such that ??⋅??+1…??−1⋅??al⋅al+1…ar−1⋅ar is positive; 

Input

The first line contains one integer ?n (1≤?≤2⋅105)(1≤n≤2⋅105) — the number of elements in the sequence.

The second line contains ?n integers ?1,?2,…,??a1,a2,…,an (−109≤??≤109;??≠0)(−109≤ai≤109;ai≠0) — the elements of the sequence.

Output

Print two integers — the number of subsegments with negative product and the number of subsegments with positive product, respectively.

Examples

input

5
5 -3 3 -1 1

output

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值