You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ non-zero integers (i.e. $a_i \ne 0$). 

You have to calculate two 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 positive; 


-----Input-----

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}; a_i \neq 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
8 7

Input
10
4 2 -4 3 1 2 -4 3 2 3

Output
28 27

Input
5
-1 -2 -3 -4 -5

Output
9 6

Difficulty: MEDIUM
Tags: Dynamic programming

Combinatorics

Implementation
Skill types: Dynamic programming

Starter code:

Solutions:
n = int(input())
a = list(map(lambda x: 1 if int(x) > 0 else -1, input().split()))
(last, pr) = (0, 1)
for q in a:
	pr *= q
	if pr > 0:
		last += 1
ans = last
for q in range(1, len(a)):
	if a[q - 1] > 0:
		last -= 1
	else:
		last = n - q - last
	ans += last
print(n * (n + 1) // 2 - ans, ans)


import math

def solve():
	cnt = [1, 0]
	ans = 0
	for i in range(1, n + 1):
		cnt[a[i]] += 1
		ans += cnt[1 ^ a[i]]
	return ans
n = int(input())
s = input()
a = list(map(int, ('0 ' + s).split()))
for i in range(n + 1):
	if a[i] >= 0:
		a[i] = 0
	else:
		a[i] = 1
	if i > 0:
		a[i] ^= a[i - 1]
ans = solve()
print(ans, n * (n + 1) // 2 - ans)


n = int(input())
a = list(map(int, input().split()))
(bal, cnt1, cnt2) = (0, 0, 0)
ansp = 0
for i in a:
	if bal % 2 == 0:
		cnt1 += 1
	else:
		cnt2 += 1
	if i < 0:
		bal += 1
	if bal % 2 == 0:
		ansp += cnt1
	else:
		ansp += cnt2
print(n * (n + 1) // 2 - ansp, ansp)


n = int(input())
a = list(map(int, input().split()))
t = 1
s = 1
f = 0
for i in range(n):
	if a[i] < 0:
		t = t * -1
	if t == 1:
		s = s + 1
	else:
		f = f + 1
d = s * f
print(d, n * (n + 1) // 2 - d)


from sys import stdin, stdout
import heapq
import cProfile, math
from collections import Counter, defaultdict, deque
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
fac_warm_up = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7

class MergeFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n
		self.lista = [[_] for _ in range(n)]

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]
		self.lista[a] += self.lista[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def prime_factors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def all_factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def fibonacci_modP(n, MOD):
	if n < 2:
		return 1
	return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * cached_fn(InverseEuler, i, p) % p
	return res

def binary(n, digits=20):
	b = bin(n)[2:]
	b = '0' * (digits - len(b)) + b
	return b

def is_prime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def generate_primes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	return prime
factorial_modP = []

def warm_up_fac(MOD):
	global factorial_modP, fac_warm_up
	if fac_warm_up:
		return
	factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]
	for i in range(2, fac_warm_up_size):
		factorial_modP[i] = factorial_modP[i - 1] * i % MOD
	fac_warm_up = True

def InverseEuler(n, MOD):
	return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
	global fac_warm_up, factorial_modP
	if not fac_warm_up:
		warm_up_fac(MOD)
		fac_warm_up = True
	return factorial_modP[n] * (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD) % MOD) % MOD

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def display_2D_list(li):
	for i in li:
		print(i)

def prefix_sum(li):
	sm = 0
	res = []
	for i in li:
		sm += i
		res.append(sm)
	return res

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def ncr(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def binary_search(i, li):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = False
fac_warm_up_size = 10 ** 5 + 100
optimise_for_recursion = False

def main():
	n = get_int()
	li = get_list()
	dp = [[0, 0]]
	posi = 0
	for i in li:
		if i > 0:
			dp.append([dp[-1][0] + 1, dp[-1][1]])
			posi += dp[-1][0]
		else:
			dp.append([dp[-1][1], dp[-1][0] + 1])
			posi += dp[-1][0]
	print(n * (n + 1) // 2 - posi, posi)
if TestCases:
	for i in range(get_int()):
		main()
else:
	main() if not optimise_for_recursion else threading.Thread(target=main).start()


n = int(input())
a = list(map(lambda x: int(int(x) > 0), input().split()))
over = [0] * n
under = [0] * n
over[0] = a[0]
under[0] = 1 - a[0]
for i in range(1, n):
	over[i] = a[i] + a[i] * over[i - 1] + (1 - a[i]) * under[i - 1]
	under[i] = 1 - a[i] + a[i] * under[i - 1] + (1 - a[i]) * over[i - 1]
print(sum(under), sum(over))


n = int(input())

def m(x):
	return -1 if int(x) < 0 else 1
l = list(map(m, input().split()))
pos = 1
neg = 0
t = 1
for x in l:
	t *= x
	if t < 0:
		neg += 1
	else:
		pos += 1
print(neg * pos, neg * (neg - 1) // 2 + pos * (pos - 1) // 2)


n = int(input())
arr = list(map(int, input().split()))
pos = 1
neg = 0
pro = 1
for i in arr:
	if i < 0:
		pro *= -1
	if pro < 0:
		neg += 1
	else:
		pos += 1
print(pos * neg, n * (n + 1) // 2 - pos * neg)


n = int(input())
arr = map(int, input().split())
wall = [1]
sum = [1, 0]
l = 1
for i in arr:
	if i > 0:
		wall[l - 1] += 1
		sum[(l - 1) % 2] += 1
	else:
		wall.append(1)
		l += 1
		sum[(l - 1) % 2] += 1
ans = [0, 0]
for i in range(l):
	ans[0] += wall[i] * sum[i % 2] - wall[i]
	ans[1] += wall[i] * sum[(i + 1) % 2]
print(str(int(ans[1] / 2)) + ' ' + str(int(ans[0] / 2)))


n = int(input())
l = list(map(int, input().split()))
arr = []
temp = 1
cnt = 0
cntp = []
ansp = 0
ansn = 0
for i in l:
	if i < 0:
		temp = temp * -1
	else:
		temp = temp * 1
	arr.append(temp)
	if temp == 1:
		cnt += 1
	cntp.append(cnt)
for i in range(n):
	if arr[i] == 1:
		ansp = ansp + cntp[i]
		ansn = ansn + i + 1 - cntp[i]
	else:
		ansp = ansp + i - cntp[i]
		ansn = ansn + cntp[i] + 1
print(ansn, ansp)


N = int(input())
A = list(map(int, input().split()))
dp = [[0, 0] for _ in range(N)]
for i in range(N):
	if i == 0:
		if A[i] > 0:
			dp[0][0] = 1
		else:
			dp[0][1] = 1
	elif A[i] > 0:
		dp[i][0] = dp[i - 1][0] + 1
		dp[i][1] = dp[i - 1][1]
	else:
		dp[i][0] = dp[i - 1][1]
		dp[i][1] = dp[i - 1][0] + 1
(a, b) = (0, 0)
for i in range(N):
	a += dp[i][0]
	b += dp[i][1]
print(b, a)


n = int(input())
l = list(map(int, input().split()))
l2 = [[0, 0] for i in range(n)]
p = 0
m = 0
if l[0] > 0:
	l2[0] = [1, 0]
	p += 1
else:
	l2[0] = [0, 1]
	m += 1
for i in range(1, n):
	if l[i] > 0:
		l2[i][0] = l2[i - 1][0] + 1
		l2[i][1] = l2[i - 1][1]
	else:
		l2[i][0] = l2[i - 1][1]
		l2[i][1] = l2[i - 1][0] + 1
	p += l2[i][0]
	m += l2[i][1]
print(m, p)


from sys import setcheckinterval, stdin, setrecursionlimit
setcheckinterval(1000)
setrecursionlimit(10 ** 7)

def iin():
	return int(stdin.readline())

def lin():
	return list(map(int, stdin.readline().split()))
n = iin()
a = lin()
(sp, sn, p, n) = (0, 0, 0, 0)
for i in a:
	if i > 0:
		p += 1
	else:
		(p, n) = (n, p)
		n += 1
	sp += p
	sn += n
print(sn, sp)


(n, s, k, p) = (int(input()), 0, 0, 1)
(*a,) = map(int, input().split())
for i in range(n):
	p *= [1, -1][a[i] < 0]
	if p > 0:
		s += k
	else:
		s += i - k + 1
		k += 1
print(s, n * (n + 1) // 2 - s)


n = int(input())
a = [int(x) for x in input().split()]
pref = [0]
for item in a:
	if item < 0:
		pref.append(pref[-1] + 1)
	else:
		pref.append(pref[-1])
non = 0
on = 0
arr = 0
for item in pref:
	if item % 2 == 0:
		arr += non
		on += 1
	else:
		arr += on
		non += 1
print(arr, n * (n + 1) // 2 - arr)


n = input()
a = [-1 if int(i) < 0 else 1 for i in input().split()]
ans = [0, 0, 0]
last = [0, 0, 0]
ans[a[0]] += 1
last[a[0]] += 1
for i in a[1:]:
	if i == 1:
		last[1] += 1
		ans[1] += last[1]
		ans[-1] += last[-1]
	elif i == -1:
		(last[1], last[-1]) = (last[-1], last[1])
		last[-1] += 1
		ans[1] += last[1]
		ans[-1] += last[-1]
print(ans[-1], ans[1])


from sys import stdin
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
n = I()
a = list(R())
d = {1: 0, 2: 0}
g = {1: 0, 2: 0}
(ps, ng) = (1, 2)
for i in a:
	if i > 0:
		d[1] += 1
		d[1] += g[ps]
		d[2] += g[ng]
		g[ps] += 1
	else:
		d[2] += 1
		(ps, ng) = (ng, ps)
		d[1] += g[ps]
		d[2] += g[ng]
		g[ng] += 1
print(d[2], d[1])


n = int(input())
a = list(map(int, input().split()))
ans_pos = 0
ans_neg = 0
tmp_pos = 0
tmp_neg = 0
for i in range(n)[::-1]:
	prev_pos = tmp_pos
	prev_neg = tmp_neg
	tmp_pos = 0
	tmp_neg = 0
	if a[i] > 0:
		tmp_pos += 1
		tmp_pos += prev_pos
		tmp_neg += prev_neg
	else:
		tmp_neg += 1
		tmp_pos += prev_neg
		tmp_neg += prev_pos
	ans_pos += tmp_pos
	ans_neg += tmp_neg
print(ans_neg, ans_pos)


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def dfs(node, adj, dp, vis):
	vis[node] = True
	for i in range(0, len(adj[node])):
		if not vis[adj[node][i]]:
			dfs(adj[node][i], adj, dp, vis)
		dp[node] = max(dp[node], 1 + dp[adj[node][i]])
from collections import defaultdict

def findSubarraySum(arr, n, Sum):
	prevSum = defaultdict(lambda : 0)
	res = 0
	currsum = 0
	for i in range(0, n):
		currsum += arr[i]
		if currsum == Sum:
			res += 1
		if currsum - Sum in prevSum:
			res += prevSum[currsum - Sum]
		prevSum[currsum] += 1
	return res
n = ii()
d = li()
t = -1
for i in range(n):
	if d[i] > 0:
		d[i] = 0
	else:
		d[i] = 1 * t
		t = -t
r = findSubarraySum(d, n, 0)
print(n + n * (n - 1) // 2 - r, r)


n = int(input())
a = list(map(int, input().split()))
prod = 1
neg = [0] * n
pos = [0] * n
if a[0] > 0:
	pos[0] = 1
else:
	neg[0] = 1
for i in range(1, len(a)):
	if a[i] >= 0:
		pos[i] = pos[i - 1] + 1
		neg[i] = neg[i - 1]
	else:
		pos[i] = neg[i - 1]
		neg[i] = pos[i - 1] + 1
print(sum(neg), sum(pos))


from sys import stdin

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))

def negSubarray(a, n):
	(neg, pos) = (0, 1)
	a = [1 if a[i] > 0 else -1 for i in range(n)]
	if a[0] == 1:
		pos += 1
	else:
		neg += 1
	for i in range(1, n):
		a[i] *= a[i - 1]
		if a[i] == 1:
			pos += 1
		else:
			neg += 1
	return pos * neg
n = iinput()
a = linput()
total = n * (n + 1) // 2
negative = negSubarray(a, n)
print(negative, total - negative)


import sys

def read_ints():
	return [int(x) for x in sys.stdin.readline().strip().split()]

def main():
	n = read_ints()[0]
	nums = read_ints()
	pos_ends = [0] * n
	neg_ends = [0] * n
	(cur_pos, cur_neg) = (1 if nums[0] > 0 else 0, 1 if nums[0] < 0 else 0)
	(total_pos, total_neg) = (cur_pos, cur_neg)
	for ix in range(1, n):
		if nums[ix] > 0:
			(cur_pos, cur_neg) = (1 + cur_pos, cur_neg)
		else:
			(cur_pos, cur_neg) = (cur_neg, 1 + cur_pos)
		total_pos += cur_pos
		total_neg += cur_neg
	print(total_neg, total_pos)
main()


from sys import stdout
from sys import stdin

def get():
	return stdin.readline().strip()

def getf(sp=' '):
	return [int(i) for i in get().split(sp)]

def put(a, end='\n'):
	stdout.write(str(a) + end)

def putf(a, sep=' ', end='\n'):
	stdout.write(sep.join([str(i) for i in a]) + end)

def main():
	n = int(get())
	a = getf()
	st = [0] * n
	cur = 1
	cnt = 0
	for i in range(n):
		if a[i] > 0:
			a[i] = 1
		else:
			a[i] = -1
		cur *= a[i]
		if cur < 0:
			cnt += 1
		st[i] = cur
	ans = 0
	for i in range(n):
		ans += cnt
		if a[i] == 1:
			pass
		else:
			cnt = n - i - cnt
	put('%d %d' % (ans, n * (n + 1) // 2 - ans))
main()


n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print(int(a[0] < 0), int(a[0] > 0))
else:
	pref = [a[0] // abs(a[0])]
	r1 = [int(a[0] // abs(a[0]) < 0)]
	r2 = [int(a[0] // abs(a[0]) > 0)]
	for i in range(1, n):
		pref.append(pref[-1] * a[i] // abs(a[i]))
		r1.append(r1[-1] + int(pref[-2] * a[i] // abs(a[i]) < 0))
		r2.append(r2[-1] + int(pref[-2] * a[i] // abs(a[i]) > 0))
	pref1 = [a[n - 1] // abs(a[n - 1])]
	for i in range(n - 2, -1, -1):
		pref1.append(pref1[-1] * a[i] // abs(a[i]))
	ans1 = 0
	ans2 = 0
	for i in range(n - 2):
		if pref1[i] < 0:
			ans1 += r2[n - i - 3] + 1
			ans2 += r1[n - i - 3]
		else:
			ans1 += r1[n - i - 3]
			ans2 += r2[n - i - 3] + 1
	ans1 += r1[-2]
	ans2 += r2[-2]
	if pref[n - 1] < 0:
		(ans1, ans2) = (ans2, ans1)
	ans1 += r1[0] + int(pref1[-1] < 0)
	ans2 += r2[0] + int(pref1[-1] > 0)
	print(ans1, ans2)


import sys, math
input = sys.stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
dp = [[0, 0] for i in range(n)]
if a[0] > 0:
	dp[0][0] = 1
else:
	dp[0][0] = 0
dp[0][1] = 1 ^ dp[0][0]
for i in range(1, n):
	if a[i] < 0:
		dp[i][0] = dp[i - 1][1]
		dp[i][1] = dp[i - 1][0] + 1
	else:
		dp[i][0] = dp[i - 1][0] + 1
		dp[i][1] = dp[i - 1][1]
p = 0
n1 = 0
for i in range(n):
	p += dp[i][0]
	n1 += dp[i][1]
print(n1, p)


import sys

def rint():
	return map(int, sys.stdin.readline().split())
n = int(input())
a = list(rint())
tmp = 1
pos = 0
neg = 0
pos_tot = 0
neg_tot = 0
for i in range(len(a)):
	if a[i] > 0:
		a[i] = 1
	else:
		a[i] = -1
for i in range(len(a)):
	tmp *= a[i]
	if tmp > 0:
		pos += 1
	else:
		neg += 1
pos_tot = pos
neg_tot = neg
for i in range(1, len(a)):
	if a[i] > 0 and a[i - 1] > 0:
		pos -= 1
	elif a[i] > 0 and a[i - 1] < 0:
		(pos, neg) = (neg, pos)
		pos -= 1
	elif a[i] < 0 and a[i - 1] < 0:
		(pos, neg) = (neg, pos)
		pos -= 1
	elif a[i] < 0 and a[i - 1] > 0:
		pos -= 1
	pos_tot += pos
	neg_tot += neg
print(neg_tot, pos_tot)


n = int(input())
l = list(map(int, input().split()))
bal = 0
p = 0
(cte, cto) = (0, 0)
for i in range(n):
	if bal % 2 == 0:
		cte += 1
	if bal % 2 == 1:
		cto += 1
	if l[i] < 0:
		bal = bal + 1
	if bal % 2 == 0:
		p = p + cte
	if bal % 2 == 1:
		p = p + cto
print(n * (n + 1) // 2 - p, p)


p = n = sum_p = sum_n = 0
_ = input()
for el in input().split():
	if el[0] == '-':
		(p, n) = (n, 1 + p)
	else:
		(p, n) = (1 + p, n)
	sum_p += p
	sum_n += n
print(sum_n, sum_p)


n = int(input())
arr = list([int(x) > 0 for x in input().split()])
pos = neg = lastpos = lastneg = curpos = curneg = 0
for i in range(n):
	if arr[i]:
		curpos = 1 + lastpos
		curneg = lastneg
	else:
		curpos = lastneg
		curneg = 1 + lastpos
	pos += curpos
	neg += curneg
	lastpos = curpos
	lastneg = curneg
print(neg, pos)


R = lambda : map(int, input().split())
n = int(input())
(poss, negs) = ([0] * (n + 1), [0] * (n + 1))
for (i, num) in enumerate(R()):
	if num > 0:
		poss[i] = 1 + poss[i - 1]
		negs[i] = negs[i - 1]
	else:
		poss[i] = negs[i - 1]
		negs[i] = 1 + poss[i - 1]
print(sum(negs), sum(poss))


n = int(input())
l = list(map(int, input().strip().split()))
pn = [0 for i in range(n)]
c = 0
d = 1
for i in range(n):
	if l[i] < 0:
		c += 1
	if c % 2 == 0:
		pn[i] = 1
p = [0 for i in range(n)]
p[0] = pn[0]
for i in range(1, n):
	p[i] = p[i - 1] + pn[i]
count = 0
if l[0] > 0:
	count += 1
for i in range(1, n):
	if pn[i] == 1:
		count += p[i - 1] + 1
	else:
		count += i - p[i - 1]
a = n * (n + 1) // 2
b = a - count
print(b, count)


n = int(input())
a = [int(i) for i in input().split()]
ans = 0
(s1, s2) = (0, 0)
for i in range(n):
	if a[i] > 0:
		s2 += 1
		ans += s2
	else:
		(s1, s2) = (s2 + 1, s1)
		ans += s2
print(n * (n + 1) // 2 - ans, ans)


from operator import add
from functools import reduce
input()

def parse(x):
	x = int(x)
	return -1 if x < 0 else 1
cn = 0

def countNegative(val):
	global cn
	cn = cn + (1 if val < 0 else 0)
	return cn
u = 0

def r(acc, val):
	(p, n) = acc
	return (p + 1, n) if (val - u) % 2 == 0 else (p, n + 1)
a = map(parse, input().split())
b = list(map(countNegative, a))
(pres, nres) = (0, 0)
c = [(0, 0) for _ in b]
(chet, nech) = (0, 0)
for i in range(len(b) - 1, -1, -1):
	if b[i] % 2 == 0:
		chet += 1
	else:
		nech += 1
	c[i] = (chet, nech)
for i in range(len(b)):
	(chet, nech) = c[i]
	if u % 2 == 0:
		pres += chet
		nres += nech
	else:
		pres += nech
		nres += chet
	u = b[i]
print(nres, pres)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	neg = [0 for _ in range(n)]
	pos = [0 for _ in range(n)]
	if a[0] > 0:
		pos[0] = 1
		neg[0] = 0
	else:
		pos[0] = 0
		neg[0] = 1
	for i in range(1, n):
		if a[i] < 0:
			neg[i] = 1 + pos[i - 1]
			pos[i] = neg[i - 1]
		else:
			pos[i] = pos[i - 1] + 1
			neg[i] = neg[i - 1]
	print(sum(neg), sum(pos))
	return
main()


n = int(input())
a = [1 if int(x) > 0 else 0 for x in input().split()]
nb_positif = 0
dp_pairs_positif = [0] * n
if a[0] == 1:
	nb_positif = 1
	dp_pairs_positif[0] = 1
for x in range(1, n):
	if a[x] == 1:
		nb_positif += 1
		dp_pairs_positif[x] = dp_pairs_positif[x - 1] + nb_positif
	else:
		nb_positif = x - nb_positif
		dp_pairs_positif[x] = dp_pairs_positif[x - 1] + nb_positif
print(str(int(n * (n + 1) / 2) - dp_pairs_positif[n - 1]) + ' ' + str(dp_pairs_positif[n - 1]))


n = int(input())
arr = [int(p) for p in input().split()]
prev = -1
val = 0
ans = [0] * n
cnt = 0
neg = []
for i in range(len(arr)):
	if arr[i] < 0:
		neg.append(i)
for i in range(len(arr)):
	if arr[i] > 0:
		ans[i] = val
	elif arr[i] < 0:
		val = i - prev
		cnt += 1
		if cnt > 2:
			val += ans[neg[cnt - 3]]
		ans[i] = val
		prev = i
print(sum(ans), n * (n + 1) // 2 - sum(ans))


from sys import stdin, stdout
for _ in range(1):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	dp = [[0 for _ in range(2)] for _ in range(n)]
	if a[0] < 0:
		dp[0][1] = 1
	else:
		dp[0][0] = 1
	for i in range(1, n):
		if a[i] < 0:
			dp[i][0] = dp[i - 1][1]
			dp[i][1] = dp[i - 1][0] + 1
		else:
			dp[i][0] = dp[i - 1][0] + 1
			dp[i][1] = dp[i - 1][1]
	pos = neg = 0
	for (p, ne) in dp:
		pos += p
		neg += ne
	print(neg, pos)


n = int(input())
a = list(map(int, input().split()))
am = 0
duong = 0
cur = 0
ans = 0
for i in range(n):
	if cur % 2 == 0:
		duong += 1
	else:
		am += 1
	if a[i] < 0:
		cur += 1
	if cur % 2 == 0:
		ans += duong
	else:
		ans += am
print(n * (n + 1) // 2 - ans, ans)


n = int(input())
dp = [0] * (n + 1)
a = list(map(int, input().split()))
for i in range(n):
	dp[i + 1] = dp[i] if a[i] >= 0 else i - dp[i] + 1
s = sum(dp)
print(s, n * (n + 1) // 2 - s)


n = int(input())
aa = list(map(int, input().split()))

def choose2(n):
	return n * (n - 1) // 2
cur = 1
pos = 1
neg = 0
for i in aa:
	if i > 0:
		cur *= 1
	else:
		cur *= -1
	if cur > 0:
		pos += 1
	else:
		neg += 1
print(pos * neg, choose2(pos) + choose2(neg))


a = int(input())
(o, e, p, n) = (0, 0, 0, 0)
for i in map(int, input().split()):
	if n % 2:
		o += 1
	else:
		e += 1
	if i < 0:
		n += 1
	if n % 2:
		p += o
	else:
		p += e
print(-p + a * (a + 1) // 2, p)


n = int(input())
dem = [0] * (n + 1)
a = list(map(int, input().split()))
for i in range(n):
	if a[i] < 0:
		dem[i + 1] = i - dem[i] + 1
	else:
		dem[i + 1] = dem[i]
d = sum(dem)
print(d, n * (n + 1) // 2 - d)


from math import *
from sys import *
from collections import defaultdict
import os, sys
from io import IOBase, BytesIO
M = 10 ** 9 + 7

def pow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a *= a
		b >>= 1
	return res

def inv(a, m):
	return powmod(a, m - 2, m)

def factor(n):
	potentional_p = 3
	itog_list = {}
	if n % 2 == 0:
		itog_list[2] = 0
	while n % 2 == 0:
		n = n // 2
		itog_list[2] += 1
	while n - 1:
		if potentional_p > n ** 0.5:
			if n in itog_list:
				itog_list[n] += 1
			else:
				itog_list[n] = 1
			return itog_list
		while n % potentional_p == 0:
			n = n // potentional_p
			if potentional_p in itog_list:
				itog_list[potentional_p] += 1
			else:
				itog_list[potentional_p] = 1
		potentional_p += 2
	return itog_list

def sign(x):
	if x > 0:
		return 1
	return -1

def sign1(x, y):
	if x * y > 0:
		return 1
	return -1

def prod(arr):
	val = 1
	for x in arr:
		val *= x
	return val

def main():
	n = int(input())
	a = list(map(int, input().split()))
	arr = []
	val = 0
	for x in a:
		if x < 0:
			arr.append(val + 1)
			val = 0
		else:
			val += 1
	arr.append(val + 1)
	sum1 = 0
	sum2 = 0
	for i in range(len(arr)):
		if i % 2 == 1:
			sum1 += arr[i]
		else:
			sum2 += arr[i]
	res = 0
	for i in range(len(arr)):
		if i % 2 == 0:
			res += arr[i] * sum1
			sum2 -= arr[i]
		else:
			res += arr[i] * sum2
			sum1 -= arr[i]
	print(res, n * (n + 1) // 2 - res)
main()


n = int(input())
nums = [int(x) for x in input().split()]
sig = 0
(po, ne) = (0, 0)
res = 0
for nu in nums:
	if nu < 0:
		(po, ne) = (ne, po + 1)
		res += po
	else:
		(po, ne) = (po + 1, ne)
		res += po
print(n * (n + 1) // 2 - res, res)


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
	if a[i] > 0:
		b.append(1)
	elif a[i] == 0:
		b.append(0)
	else:
		b.append(-1)
pre = [1] * n
less_zero = [0] * n
more_zero = [0] * n
pre[0] = b[0]
left = [1] * n
right = [1] * n
right[0] = b[0]
for i in range(1, n):
	left[i] = left[i - 1] * b[i - 1]
	right[i] = right[i - 1] * b[i]
less_zero[0] += int(left[0] < 0)
more_zero[0] += int(left[0] > 0)
for i in range(1, n):
	less_zero[i] = less_zero[i - 1] + int(left[i] < 0)
	more_zero[i] = more_zero[i - 1] + int(left[i] > 0)
more = 0
less = 0
for i in range(n):
	if right[i] > 0:
		less += less_zero[i]
		more += more_zero[i]
	else:
		more += less_zero[i]
		less += more_zero[i]
print(less, more)


mod = 10 ** 9 + 7
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import collections
import math

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	t = int(input())
	l = ain()
	p = n = pp = nn = 0
	for i in l:
		if i > 0:
			p = p + 1
			pp += p
			nn += n
		else:
			(p, n) = (n, p)
			n = n + 1
			nn += n
			pp += p
	print(nn, pp)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = list(map(int, input().split()))
neg = 0
pos1 = 0
pos2 = 0
dp = []
numneg = 0
h = []
k = 0
for i in range(n):
	if a[i] > 0:
		if numneg % 2 == 0:
			pos1 += 1
		else:
			pos2 += 1
	else:
		numneg += 1
		if numneg % 2 == 0:
			pos1 += 1
		elif numneg > 1:
			pos2 += 1
pos = pos1 * (pos1 + 1) // 2 + pos2 * (pos2 + 1) // 2
print(n * (n + 1) // 2 - pos, pos)


from sys import stdin

def products(arr, n):
	pos = [0] * (n + 1)
	neg = [0] * (n + 1)
	for i in range(n):
		v = arr[i]
		if v > 0:
			pos[i] = pos[i - 1] + 1
			neg[i] = neg[i - 1]
		else:
			pos[i] = neg[i - 1]
			neg[i] = pos[i - 1] + 1
	print(sum(neg))
	print(sum(pos))

def solution():
	input = stdin.readline
	n = int(input())
	arr = [int(x) for x in input().split()]
	products(arr, n)
solution()


n = int(input())
l1 = list(map(int, input().split()))
negative = 0
total = n * (n + 1) // 2
negative_till = 0
positive_till = 0
for item in l1:
	if item > 0:
		positive_till += 1
	else:
		temp = positive_till
		positive_till = negative_till
		negative_till = temp + 1
	negative += negative_till
print(negative, total - negative)


from collections import Counter, defaultdict, deque
import heapq as hq
import math
import sys

def sign(x):
	return 1 - 2 * (x < 0)
input = sys.stdin.readline
n = int(input())
arr = [int(x) for x in input().split()]
color = 1
cblue = 0
cred = 0
c = 0
for el in arr:
	if color:
		cblue += 1
	else:
		cred += 1
	if el > 0:
		if color:
			c += cblue
		else:
			c += cred
	else:
		if color:
			c += cred
		else:
			c += cblue
		color ^= 1
print(n * (n + 1) // 2 - c, c)


n = int(input())
a = list(map(int, input().split()))
for i in range(1, n):
	a[i] *= a[i - 1]
	if a[i] > 0:
		a[i] = 1
	else:
		a[i] = -1
p = ne = 0
for i in a:
	if i > 0:
		p += 1
	else:
		ne += 1
print(p * ne + ne, p * (p + 1) // 2 + ne * (ne - 1) // 2)


n = int(input())
nums = list(map(int, input().split()))
psum = [0]
psum1 = [0]
total = n * (n + 1) // 2
for i in range(n):
	psum.append(psum[i] ^ (nums[i] < 0))
for i in range(1, n + 1):
	psum1.append(psum1[i - 1] + psum[i])
positive = 0
for i in range(1, n + 1):
	if psum[i] == 1:
		positive += psum1[i - 1]
	else:
		positive += i - psum1[i - 1]
print(total - positive, positive)


import sys
input = sys.stdin.readline

def One(type):
	return type(input())

def List(type):
	return list(map(type, input().split()))

def Str():
	return list(input())

def Many(type):
	return map(type, input().split())

def main():
	n = One(int)
	m = List(int)
	ansp = ansn = 0
	neg = []
	for (i, nxt) in enumerate(m):
		if nxt < 0:
			neg.append(i)
	odd = even = 0
	for (i, nxt) in enumerate(neg):
		if i == 0:
			even += nxt + 1
			ansn += nxt + 1
			ansp += nxt * (nxt + 1) // 2
			continue
		val = nxt - neg[i - 1]
		if i % 2 == 1:
			ansp += val * (val - 1) // 2 + even + odd * (val - 1)
			ansn += even * (val - 1) + val + odd
			odd += val
		else:
			ansp += val * (val - 1) // 2 + odd + even * (val - 1)
			ansn += odd * (val - 1) + val + even
			even += val
	if len(neg) > 0:
		if neg[len(neg) - 1] < n - 1:
			val = n - 1 - neg[len(neg) - 1]
			ansp += val * (val + 1) // 2 + (even if len(neg) % 2 == 0 else odd) * val
			ansn += val * (odd if len(neg) % 2 == 0 else even)
	else:
		ansp += n * (n + 1) // 2
	print(ansn, ansp)
main()


n = int(input())
a = [int(x) for x in input().split()]
prev_p = 0
prev_n = 0
total_p = 0
total_n = 0
for i in range(n):
	if a[i] > 0:
		prev_p += 1
	else:
		(prev_p, prev_n) = (prev_n, prev_p)
		prev_n += 1
	total_p += prev_p
	total_n += prev_n
print(total_n, total_p)


import sys
input = sys.stdin.readline
out = sys.stdout

def main():
	n = int(input())
	a = list(map(int, input().split()))
	(pos, neg) = (0, 0)
	(prev_pos, prev_neg) = (0, 0)
	for i in range(n):
		if a[i] > 0:
			prev_pos += 1
			pos += prev_pos
			neg += prev_neg
		else:
			carry = prev_neg
			prev_neg = prev_pos + 1
			neg += prev_neg
			prev_pos = carry
			pos += prev_pos
	print(neg, pos)
main()


n = int(input())
l = list(map(int, input().split()))
ne = p = 0
an = ap = 0
if l[0] < 0:
	c = -1
	an = ne = 1
else:
	c = 1
	ap = p = 1
for i in range(1, n):
	if l[i] > 0:
		p += 1 + ap
		ne += an
	else:
		ne += 1 + ap
		p += an
	c = c * (l[i] // abs(l[i]))
	if l[i] < 0:
		(an, ap) = (ap + 1, an)
	else:
		ap += 1
print(ne, p)


def solve(a, n):
	neg = [0 for i in range(n)]
	pos = [0 for i in range(n)]
	if a[0] < 0:
		neg[0] = 1
	else:
		pos[0] = 1
	for i in range(1, n):
		if a[i] < 0:
			neg[i] += 1 + pos[i - 1]
			pos[i] += neg[i - 1]
		else:
			pos[i] += 1 + pos[i - 1]
			neg[i] += neg[i - 1]
	totalNeg = 0
	totalPos = 0
	for i in range(n):
		totalNeg += neg[i]
		totalPos += pos[i]
	return (totalNeg, totalPos)
n = int(input())
a = list(map(int, input().split()))
(l, r) = solve(a, n)
print(str(l) + ' ' + str(r))


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
b[n - 1] = 0
c = [0] * n
k = 1
for i in range(n):
	if a[i] < 0:
		k = k * -1
	c[i] = k
for i in range(n - 2, -1, -1):
	if c[i + 1] < 0:
		b[i] = b[i + 1] + 1
	else:
		b[i] = b[i + 1]
pos = 0
neg = 0
for i in range(n):
	if a[i] > 0 and c[i] > 0:
		neg += b[i]
		pos += n - i - b[i]
	elif a[i] < 0 and c[i] < 0:
		neg += b[i] + 1
		pos += n - i - b[i] - 1
	elif a[i] > 0 and c[i] < 0:
		pos += b[i] + 1
		neg += n - i - b[i] - 1
	else:
		pos += b[i]
		neg += n - i - b[i]
print(str(neg) + ' ' + str(pos))


n = int(input())
l = list(map(int, input().split()))
a = []
c = 0
a.append(c)
for i in range(n):
	if l[i] < 0:
		c += 1
	a.append(c)
x = 0
y = 0
pos = 0
for i in range(len(a)):
	if a[i] % 2 == 0:
		pos += x
		x += 1
	else:
		pos += y
		y += 1
neg = n * (n + 1) // 2 - pos
print(neg, pos)


import collections
n = int(input())
a = list(map(int, input().split()))
(curr, odd, even) = (0, 0, 0)
p = 0
for d in a:
	(odd, even) = ((odd, even + 1), (odd + 1, even))[curr % 2]
	curr += 1 if d < 0 else 0
	p += odd if curr % 2 else even
print(n * (n + 1) // 2 - p, p)


n = int(input())
nums = list(map(int, input().split()))
n_neg = 0
n_pos = 0
n_curr_neg = 0
n_curr_pos = 0
for (i, el) in enumerate(nums):
	if el > 0:
		n_curr_pos += 1
		n_curr_neg = n_curr_neg
	else:
		(n_curr_pos, n_curr_neg) = (n_curr_neg, n_curr_pos)
		n_curr_neg += 1
	n_pos += n_curr_pos
	n_neg += n_curr_neg
print(n_neg, n_pos)


n = int(input())
l = list(map(int, input().split()))
n = 0
p = 0
cp = 0
cn = 0
for i in l:
	if i < 0:
		(cp, cn) = (cn, cp)
		cn += 1
	else:
		cp += 1
	n += cn
	p += cp
print(n, p)


n = int(input())
a = list(map(int, input().split()))
dp1 = [0] * n
dp2 = [0] * n
if 0 < a[0]:
	dp1[0] = 1
if 0 > a[0]:
	dp2[0] = 1
for i in range(1, n):
	if 0 < a[i]:
		dp1[i] = dp1[i - 1] + 1
		dp2[i] = dp2[i - 1]
	if 0 > a[i]:
		dp1[i] = dp2[i - 1]
		dp2[i] = dp1[i - 1] + 1
pos = sum(dp1)
neg = sum(dp2)
print(neg, pos)


n = int(input())
l = list(map(int, input().split()))
ll = []
if l[0] < 0:
	cou = [1]
else:
	cou = [0]
if l[0] > 0:
	coup = [1]
else:
	coup = [0]
for i in range(n):
	if l[i] < 0:
		ll.append(-1)
	else:
		ll.append(1)
for i in range(1, n):
	ll[i] = ll[i - 1] * ll[i]
	if ll[i] < 0:
		cou.append(cou[i - 1] + 1)
	else:
		cou.append(cou[i - 1])
	if ll[i] > 0:
		coup.append(coup[i - 1] + 1)
	else:
		coup.append(coup[i - 1])
res = 0
for i in range(n):
	if ll[i] < 0:
		res += coup[i] + 1
	else:
		res += cou[i]
print(res, n * (n + 1) // 2 - res)


n = int(input())
a = map(int, input().split())
n = 0
p = 0
cn = 0
cp = 0
for i in a:
	if i < 0:
		(cn, cp) = (cp, cn)
		cn += 1
	else:
		cp += 1
	n += cn
	p += cp
print(n, p)


from collections import defaultdict as DD
from bisect import bisect_left as BL
from bisect import bisect_right as BR
from itertools import combinations as IC
from itertools import permutations as IP
from random import randint as RI
import sys
MOD = pow(10, 9) + 7

def IN(f=0):
	if f == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())

def count(ar, n):
	temp = [1, 0]
	result = 0
	val = 0
	for i in range(n):
		val = ((val + ar[i]) % 2 + 2) % 2
		temp[val] += 1
	result = temp[0] * temp[1]
	return result

def fnx(t):
	if t > 0:
		return 0
	else:
		return 1
n = IN(1)
a = IN()
n = len(a)
h = []
for i in range(n):
	h.append(fnx(a[i]))
p = count(h, n)
u = n * (n + 1) // 2
print(p, u - p)


n = int(input())
a = [int(x) for x in input().split()]
N = n * (n + 1) // 2
total = 0
pos = 0
for i in range(0, n):
	if a[i] < 0:
		pos = i - pos
		total += pos
	else:
		pos += 1
		total += pos
print(N - total, total)


n = int(input())
a = map(int, input().split())
(cnt_plus, cnt_minus) = (0, 0)
(cur_plus, cur_minus) = (0, 0)
for v in a:
	if v > 0:
		cur_plus += 1
	else:
		(cur_minus, cur_plus) = (cur_plus + 1, cur_minus)
	cnt_plus += cur_plus
	cnt_minus += cur_minus
print(cnt_minus, cnt_plus)


from itertools import accumulate
from operator import xor
n = int(input())
l = accumulate([1 if x < 0 else 0 for x in map(int, input().split())], xor)
a = b = 0
cnt = [1, 0]
for e in l:
	a += cnt[e ^ 1]
	b += cnt[e]
	cnt[e] += 1
print(a, b)


n = int(input())
a = [int(x) for x in input().split()]
dpn = 1 if a[0] < 0 else 0
dpp = 1 - dpn
(ng, ps) = (dpn, dpp)
for i in range(1, n):
	if a[i] > 0:
		dpp += 1
	else:
		(dpn, dpp) = (dpp + 1, dpn)
	ng += dpn
	ps += dpp
print(ng, ps)


from sys import stdin, stdout
import sys
from bisect import bisect_left, bisect_right
import heapq
sys.setrecursionlimit(2 * 10 ** 5)
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().strip().split(' ')))
arr = [1] + arr
for i in range(len(arr)):
	if arr[i] > 0:
		arr[i] = 1
	else:
		arr[i] = -1
for i in range(1, len(arr)):
	arr[i] = arr[i] * arr[i - 1]
ctr0 = 0
ctr1 = 0
for i in arr:
	if i == 1:
		ctr1 += 1
	else:
		ctr0 += 1
pos = ctr1 * (ctr1 - 1) // 2 + ctr0 * (ctr0 - 1) // 2
neg = n * (n + 1) // 2 - pos
stdout.write(str(neg) + ' ' + str(pos) + '\n')


elem = int(input())
ar = []
countPlus = 0
countMin = 0
temp = []
for t in input().split(' '):
	if len(temp) == 0:
		if int(t) > 0:
			countPlus = 1
			temp.append(1)
			ar.append(1)
		else:
			countMin = 1
			temp.append(-1)
			ar.append(-1)
	elif int(t) > 0:
		if temp[-1] == -1:
			countMin = countMin + 1
		else:
			countPlus = countPlus + 1
		temp.append(temp[-1])
		ar.append(1)
	else:
		if temp[-1] == -1:
			countPlus = countPlus + 1
		else:
			countMin = countMin + 1
		temp.append(-1 * temp[-1])
		ar.append(-1)
plus = 0
minus = 0
for x in ar:
	if x == 1:
		plus = plus + countPlus
		minus = minus + countMin
		countPlus = countPlus - 1
	else:
		plus = plus + countPlus
		minus = minus + countMin
		countMin = countMin - 1
		temp2 = countMin
		countMin = countPlus
		countPlus = temp2
print(minus, plus)


def main():
	n = int(input())
	seq = [int(c) for c in input().split()]
	acc = [0]
	for i in range(n):
		acc.append((acc[-1] + 1) % 2 if seq[i] < 0 else acc[-1])
	zeros = [0] if acc[0] == 1 else [1]
	ones = [0] if acc[0] == 0 else [1]
	for i in range(1, len(acc)):
		zeros.append(zeros[-1] + 1 if acc[i] == 0 else zeros[-1])
		ones.append(ones[-1] + 1 if acc[i] == 1 else ones[-1])
	neg = 0
	for (i, e) in enumerate(acc):
		neg += ones[i] if e == 0 else zeros[i]
	print(neg, n * (n + 1) // 2 - neg)
main()


import math
a = int(input())
b = list(map(int, input().strip().split()))
positive = [0]
negative = [0]
nans = 0
pans = 0
for i in range(1, a + 1, 1):
	if b[i - 1] > 0:
		positive.append(positive[i - 1] + 1)
		negative.append(negative[i - 1])
	else:
		positive.append(negative[i - 1])
		negative.append(positive[i - 1] + 1)
	nans += negative[i]
	pans += positive[i]
print(nans, pans)


n = int(input())
a = list(map(int, input().split()))
d = [None] * n
(pos, neg) = (1, 0) if a[0] > 0 else (0, 1)
d[0] = (pos, neg)
h = [None] * n
h[0] = (pos, neg)
for i in range(1, n):
	if a[i] > 0:
		(dp, dn) = (pos + 1, neg)
		pos += 1
	else:
		(dp, dn) = (neg, pos + 1)
		(pos, neg) = (neg, pos)
		neg += 1
	h[i] = (dp, dn)
	(p, n) = d[i - 1]
	d[i] = (p + dp, n + dn)
(pos, neg) = d[-1]
print(neg, pos)


n = int(input())
l = list(map(int, input().split()))
dp = []
neg = 0
pos = 0
if l[0] < 0:
	t = [0, 1]
else:
	t = [1, 0]
dp.append(t)
for i in range(1, n):
	t = dp[-1]
	tl = [0, 0]
	if l[i] < 0:
		tl[1] = t[0] + 1
		tl[0] = t[1]
	else:
		tl[0] = t[0] + 1
		tl[1] = t[1]
	dp.append(tl)
for i in range(0, n):
	neg += dp[i][1]
	pos += dp[i][0]
print(neg, pos)


import sys
input = sys.stdin.readline
t = 1
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	total = n * (n + 1) // 2
	neg = 0
	pos = 0
	ans = 0
	for i in range(n):
		if a[i] < 0:
			temp = neg
			neg = pos + 1
			pos = temp
		else:
			pos += 1
			neg = neg
		ans += neg
	print(ans, total - ans)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect
from collections import deque, defaultdict, OrderedDict
N = 1000001
p = 10 ** 9 + 7
fact = [None] * (N + 1)
fact[0] = 1
for i in range(1, N + 1):
	fact[i] = fact[i - 1] * i % p

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(1):
		n = ri()
		a = ria()
		ans = 0
		cup = 0
		prev = 0
		c = 0
		em = 0
		om = 0
		tot = n * (n + 1) // 2
		for i in range(n):
			if a[i] < 0:
				c += 1
				z = ans
				if c % 2 == 0:
					ans += i + 1 - prev + em
					em += i + 1 - prev
				else:
					ans += i + 1 - prev + om
					om += i + 1 - prev
				cup = ans - z
				prev = i + 1
			else:
				ans += cup
		print(ans, tot - ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import *
(n,) = I()
l = I()
l = [i / abs(i) for i in l]
pneg = 0
ppos = 0
neg = 0
pos = 0
a = 0
for i in range(n):
	if l[i] < 0:
		a += 1
	if a % 2:
		pos += pneg
		pneg += 1
		neg += ppos + 1
	else:
		ppos += 1
		pos += ppos
		neg += pneg
print(neg, pos)


n = int(input())
a = list(map(int, input().strip().split(' ')))
positive = [0] * n
negative = [0] * n
if a[0] < 0:
	negative[0] += 1
else:
	positive[0] += 1
for i in range(1, n):
	if a[i] > 0:
		positive[i] = positive[i - 1] + 1
		negative[i] = negative[i - 1]
	else:
		negative[i] = positive[i - 1] + 1
		positive[i] = negative[i - 1]
print(sum(negative), sum(positive))


I = lambda : int(input())
sign = lambda x: -1 if x < 0 else 1
LI = lambda : [sign(int(x)) for x in input().split()]
c = lambda x: x * (x - 1) // 2
n = I()
a = LI()
for i in range(1, len(a)):
	a[i] *= a[i - 1]
p = 0
i = 0
for x in a:
	if x == -1:
		i += 1
	else:
		p += 1
print(c(n) + n - (c(p) + c(i) + p), c(p) + c(i) + p)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		p = m = 0
		ap = am = 0
		for c in a:
			if c < 0:
				(p, m) = (m, p + 1)
			else:
				p += 1
			ap += p
			am += m
		rr.append(JA([am, ap], ' '))
	return JA(rr, '\n')
print(main())


import sys
import os
from io import BytesIO, IOBase

def cel(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return defaultdict(int)

def ddl():
	return defaultdict(list)

def ddd():
	return defaultdict(defaultdict(int))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict
from heapq import *
from queue import PriorityQueue
n = ii()
a = li()
(prev_pv, prev_nv) = (0, 0)
(ans_pv, ans_nv) = (0, 0)
for i in range(n):
	if a[i] > 0:
		prev_pv = 1 + prev_pv
		ans_pv += prev_pv
		ans_nv += prev_nv
	else:
		tmp = prev_nv
		prev_nv = 1 + prev_pv
		ans_nv += prev_nv
		prev_pv = tmp
		ans_pv += prev_pv
print(ans_nv, ans_pv)


import sys
from math import ceil, floor
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
mod = 10 ** 7 + 1
n = int(ri())
a = RI()
pos = [0] * n
neg = [0] * n
if a[0] < 0:
	neg[0] = 1
else:
	pos[0] = 1
ansp = 0
ansn = 0
for i in range(1, n):
	if a[i] > 0:
		if a[i - 1] > 0:
			pos[i] = pos[i - 1] + 1
			neg[i] = neg[i - 1]
		else:
			pos[i] = pos[i - 1] + 1
			neg[i] = neg[i - 1]
	elif a[i - 1] > 0:
		pos[i] = neg[i - 1]
		neg[i] = pos[i - 1] + 1
	else:
		pos[i] = neg[i - 1]
		neg[i] = pos[i - 1] + 1
	ansp += pos[i]
	ansn += neg[i]
print(ansn + neg[0], ansp + pos[0])


n = int(input())
l = list(map(int, input().split()))
dp = [[0 for i in range(2)] for j in range(n)]
dp[0][0] = 1
dp[0][1] = 1
if l[0] < 0:
	dp[0][0] = 0
else:
	dp[0][1] = 0
for i in range(1, n):
	if l[i] > 0:
		dp[i][0] = dp[i - 1][0] + 1
		dp[i][1] = dp[i - 1][1]
	else:
		dp[i][1] = dp[i - 1][0] + 1
		dp[i][0] = dp[i - 1][1]
ans = 0
ans1 = 0
for i in range(n):
	ans += dp[i][0]
	ans1 += dp[i][1]
print(ans1, ans)


import sys, bisect
input = sys.stdin.readline

def inp():
	return int(input().rstrip())

def inlt():
	return list(map(int, input().rstrip().split()))

def insr():
	s = input().rstrip()
	return s[:len(s) - 1]

def invr():
	return map(int, input().rstrip().split())
ne = inp()
nums = [1 if i > 0 else -1 for i in inlt()]
p = [0 for i in range(ne)]
n = [0 for i in range(ne)]
pcnt = 0
ncnt = 0
s = 1
for i in range(ne):
	s *= nums[i]
	if s > 0:
		pcnt += 1
	else:
		ncnt += 1
	p[i] = pcnt
	n[i] = ncnt
pans = 0
for i in range(ne):
	pans += p[-1]
	if nums[i] > 0:
		p[-1] -= 1
	else:
		n[-1] -= 1
		temp = n[-1]
		n[-1] = p[-1]
		p[-1] = temp
total = ne * (ne + 1) // 2
nans = total - pans
print(nans, pans)


__ = input()
arr = map(int, input().split())
pos = [0]
neg = [0]
for a in arr:
	if a > 0:
		pos.append(pos[-1])
		neg.append(neg[-1])
		pos[-1] += 1
	else:
		neg.append(pos[-1])
		pos.append(neg[-2])
		neg[-1] += 1
print(sum(neg), sum(pos))


import sys
input = sys.stdin.readline
inf = int(10000000000.0)
n = int(input())
lis = tuple(map(int, input().split()))
neg = [0] * n
pos = [0] * n
if lis[0] > 0:
	pos[0] = 1
else:
	neg[0] = 1
for i in range(1, n):
	if lis[i] > 0:
		pos[i] += 1 + pos[i - 1]
		neg[i] += neg[i - 1]
	else:
		pos[i] += neg[i - 1]
		neg[i] += 1 + pos[i - 1]
print(sum(neg), sum(pos))


n = int(input()) + 1
a = [0] + list(map(int, input().split()))
acc = [[0, 0] for _ in range(n)]
sign = 0
for i in range(1, n):
	sign ^= a[i] < 0
	acc[i][0] = acc[i - 1][0]
	acc[i][1] = acc[i - 1][1]
	acc[i][sign] += 1
ans = [0, 0]
sign = 0
for i in range(1, n):
	ans[1] += acc[-1][sign] - acc[i - 1][sign]
	ans[0] += acc[-1][sign ^ 1] - acc[i - 1][sign ^ 1]
	sign ^= int(a[i] < 0)
print(*ans)


from math import *

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
n = int(input())
l = list(map(int, input().split()))
d = dict()
d1 = dict()
a = [0, 0, 0]
for i in range(n - 1, -1, -1):
	if l[i] > 0:
		d1[1] = 1
	else:
		d1[-1] = 1
	for (key, val) in d.items():
		if l[i] * key > 0:
			v = 1
		else:
			v = -1
		if v in d1:
			d1[v] += val
		else:
			d1[v] = val
	d = d1
	for (key, val) in d1.items():
		a[key] += val
	d1 = dict()
print(a[2], a[1])


n = int(input())
a = list(map(int, input().split()))
neg_nend = 0
pos_nend = 0
neg_end = 0
pos_end = 0
for x in a:
	neg_nend += neg_end
	pos_nend += pos_end
	if x > 0:
		(neg_end, pos_end) = (neg_end, pos_end + 1)
	else:
		(neg_end, pos_end) = (pos_end + 1, neg_end)
print(neg_nend + neg_end, pos_nend + pos_end)


def fun(x):
	if int(x) < 0:
		return -1
	return 1
m = int(input())
a = list(map(fun, input().split()))
for i in range(1, m):
	a[i] *= a[i - 1]
(n, p) = (0, 0)
(tn, tp) = (a.count(-1), a.count(1))
for i in range(m - 1, -1, -1):
	if a[i] == -1:
		tp += n
		tn += p
		n += 1
	else:
		tp += p
		tn += n
		p += 1
print(tn, tp)


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	n = ri()
	A = rl()
	pref = [0]
	for a in A:
		if a < 0:
			pref.append(1 - pref[-1])
		else:
			pref.append(pref[-1])
	evens = 0
	odds = 0
	ans = 0
	for p in pref:
		if p == 0:
			ans += odds
			evens += 1
		else:
			ans += evens
			odds += 1
	print(ans, n * (n + 1) // 2 - ans)
mode = 's'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


import sys, os, io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	c = dict(Counter(l))
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieveForSmallestPrimeFactor():
	MAXN = 100001
	spf = [0 for i in range(MAXN)]
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, math.ceil(math.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
	return spf

def getPrimeFactorizationLOGN(x):
	spf = sieveForSmallestPrimeFactor()
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def si():
	return input()

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def solve():
	n = ii()
	a = li()
	cntOdd = 0
	cntEven = 0
	minus = 0
	ans = 0
	for i in range(n):
		if minus % 2 == 0:
			cntEven += 1
		else:
			cntOdd += 1
		if a[i] < 0:
			minus += 1
		if minus % 2 == 0:
			ans += cntEven
		else:
			ans += cntOdd
	print(n * (n + 1) // 2 - ans, ans)
t = 1
for _ in range(t):
	solve()


n = int(input())
l = list(map(int, input().split()))
total = n * (n + 1) // 2
x = -1
i = 0
neg = 0
x = []
for i in range(n):
	if l[i] < 0:
		x.append(i + 1)
if len(x) == 0:
	print(0, total)
else:
	t = [x[0]]
	for i in range(1, len(x)):
		t.append(x[i] - x[i - 1])
	t.append(n + 1 - x[-1])
	(sum1, sum2) = (0, 0)
	for i in range(len(t)):
		if i & 1:
			sum1 += t[i]
		else:
			sum2 += t[i]
	(t1, t2) = (0, 0)
	for i in range(len(t)):
		if i & 1:
			neg += t[i] * sum2
			sum1 -= t[i]
		else:
			neg += t[i] * sum1
			sum2 -= t[i]
	print(neg, total - neg)


import sys
from copy import *
from bisect import *
from itertools import permutations as prm, product

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def string(s):
	return ''.join(s)

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = 1
while t > 0:
	t -= 1
	k = 0
	n = fi()
	a = li()
	for i in range(n):
		a[i] = 1 if a[i] > 0 else -1
	dp = [[0] * 2 for i in range(n)]
	ans = [0, 0]
	for i in range(n):
		if i == 0:
			dp[i][0] = int(a[i] > 0)
			dp[i][1] = int(a[i] < 0)
		elif a[i] > 0:
			dp[i][0] = dp[i - 1][0] + 1
			dp[i][1] = dp[i - 1][1]
		else:
			dp[i][0] = dp[i - 1][1]
			dp[i][1] = dp[i - 1][0] + 1
		for k in [0, 1]:
			ans[k] += dp[i][k]
	print(*ans[::-1])


ntotal = 0
ptotal = 0
negCountsIncludingIndex = 0
posCountsIncludingIndex = 0
prevn = 0
prevp = 0
n = int(input())
a = [int(x) for x in input().split()]
for i in range(n):
	if a[i] < 0:
		negCountsIncludingIndex = prevp + 1
		posCountsIncludingIndex = prevn
	else:
		posCountsIncludingIndex += 1
	ntotal += negCountsIncludingIndex
	ptotal += posCountsIncludingIndex
	prevp = posCountsIncludingIndex
	prevn = negCountsIncludingIndex
print('{} {}'.format(ntotal, ptotal))


n = int(input())
a = list(map(int, input().split()))
p = 0
q = 0
k = False
t = 0
ans = 0
a.reverse()
for i in range(n):
	if a[i] < 0:
		k = True
	if t:
		q += 1
	else:
		p += 1
	if a[i] < 0:
		t = t ^ 1
	if k and t:
		ans += p
	elif k:
		ans += q
print(ans, n * (n + 1) // 2 - ans)


n = int(input())
a = [int(i) for i in input().split()]
cur = -1
neg = []
for i in range(n):
	if a[i] < 0:
		neg.append(i - cur)
		cur = i
for i in range(2, len(neg)):
	neg[i] += neg[i - 2]
cnt = -1
ans = 0
for i in range(n):
	if a[i] < 0:
		cnt += 1
	if cnt >= 0:
		ans += neg[cnt]
print(ans, n * (n + 1) // 2 - ans)


n = int(input())
lst = list(map(int, input().split(' ')))
(P, N, ct) = ([0] * n, [0] * n, 0)
for i in range(n):
	ct += lst[i] < 0
	if ct & 1:
		N[i] = 1
	else:
		P[i] = 1
for i in range(n - 2, -1, -1):
	P[i] += P[i + 1]
	N[i] += N[i + 1]
(a, b) = (0, 0)
for i in range(n):
	a += P[i]
	b += N[i]
	if lst[i] < 0:
		(N, P) = (P, N)
print(b, a, sep=' ')


n = int(input())
l = [int(i) for i in input().split()]
total = n * (n + 1) // 2
pos = 1
neg = 0
p = 1
sol = 0
for i in l:
	p *= i
	if p >= 0:
		sol += pos
		pos += 1
		p = 1
	else:
		sol += neg
		neg += 1
		p = -1
print(str(total - sol) + ' ' + str(sol))


n = int(input())
l = list(map(int, input().split()))
l1 = []
for i in range(n):
	if i == 0:
		if l[i] > 0:
			l1.append(1)
		else:
			l1.append(-1)
	elif l[i] > 0:
		l1.append(l1[i - 1] * 1)
	else:
		l1.append(l1[i - 1] * -1)
l2 = [0] * n
l3 = [0] * n
(c, d) = (0, 0)
for i in range(n - 1, -1, -1):
	if l1[i] > 0:
		c += 1
	else:
		d += 1
	l2[i] = c
	l3[i] = d
(ans1, ans2) = (d, c)
for i in range(1, n):
	if l1[i - 1] > 0:
		ans1 += l3[i]
		ans2 += l2[i]
	else:
		ans1 += l2[i]
		ans2 += l3[i]
print(ans1, ans2)


input()
a = list(map(int, input().split()))
(q, w, e, t, y) = (0, 0, 1, 0, 0)
for i in a:
	if e > 0:
		q += 1
		if i > 0:
			e = 1
		else:
			e = -1
	else:
		w += 1
		if i > 0:
			e = -1
		else:
			e = 1
	if e > 0:
		t += q
		y += w
	else:
		t += w
		y += q
print(y, t)


n = int(input())
nums = [int(x) for x in input().split()]
bal = 0
p = 0
ng = 0
ans = 0
for i in nums:
	if bal % 2 == 0:
		p += 1
	else:
		ng += 1
	if i < 0:
		bal += 1
	if bal % 2 == 0:
		ans = ans + p
	else:
		ans = ans + ng
tot = n * (n + 1) // 2
print(tot - ans, ans)


n = int(input())
a = list(map(int, input().split()))

def sign(x):
	return x // abs(x) == 1
pos = True
(p, m) = (0, 0)
for i in a:
	if sign(i) and pos:
		p += 1
	elif sign(i):
		m += 1
	elif pos:
		pos = False
		m += 1
	else:
		pos = True
		p += 1
(ptotal, mtotal) = (p, m)
for i in range(1, n):
	if sign(a[i - 1]):
		(p, m) = (p - 1, m)
	else:
		(p, m) = (m - 1, p)
	(ptotal, mtotal) = (ptotal + p, mtotal + m)
print(mtotal, ptotal)


n = int(input())
l = [int(j) for j in input().split()]
dp = [[0, 0] for i in range(n)]
if l[0] > 0:
	dp[0] = [1, 0]
else:
	dp[0] = [0, 1]
for i in range(1, n):
	if l[i] > 0:
		dp[i][0] = dp[i - 1][0] + 1
		dp[i][1] = dp[i - 1][1]
	else:
		dp[i][0] = dp[i - 1][1]
		dp[i][1] = dp[i - 1][0] + 1
an1 = 0
an2 = 0
for i in range(n):
	an1 += dp[i][0]
	an2 += dp[i][1]
print(an2, an1)


n = int(input())
arr = [int(x) for x in input().split()]
neg = pos = minus = plus = 0
for i in arr:
	if i < 0:
		(plus, minus) = (minus, plus)
		minus += 1
	else:
		plus += 1
	pos += plus
	neg += minus
print(neg, pos)


n = int(input())
a = list(map(int, input().split(' ')))
dpp = [0] * n
dpn = [0] * n
for i in range(0, n):
	if a[i] > 0:
		dpp[i] = 1
	elif a[i] < 0:
		dpn[i] = 1
for i in range(1, n):
	if a[i] > 0:
		dpn[i] += dpn[i - 1]
		dpp[i] += dpp[i - 1]
	elif a[i] < 0:
		dpn[i] += dpp[i - 1]
		dpp[i] += dpn[i - 1]
ps = 0
ns = 0
for x in dpp:
	ps += x
for x in dpn:
	ns += x
print(ns, ps)


l = int(input())
a = [int(x) for x in input().split()]
N = {0: int(a[0] < 0)}
P = {0: 1 - N[0]}
n = N[0]
p = P[0]
for i in range(1, l):
	if a[i] >= 0:
		P[i] = P[i - 1] + 1
		N[i] = i + 1 - P[i]
	else:
		N[i] = P[i - 1] + 1
		P[i] = i + 1 - N[i]
	p += P[i]
	n += N[i]
print(n, p)


n = int(input())
a = list(map(int, input().split()))
dp = [[0 for i in range(2)] for j in range(n)]
dp[0][1] = 1 if a[0] < 0 else 0
dp[0][0] = 1 if a[0] > 0 else 0
for i in range(1, n):
	if a[i] > 0:
		dp[i][0] = 1 + dp[i - 1][0]
		dp[i][1] = dp[i - 1][1]
	else:
		dp[i][0] = dp[i - 1][1]
		dp[i][1] = 1 + dp[i - 1][0]
pos = 0
neg = 0
for i in range(n):
	pos += dp[i][0]
	neg += dp[i][1]
print(neg, pos)


import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
curr = 1
neg = 0
for i in range(n):
	curr *= 1 if a[i] > 0 else -1
	if curr < 0:
		neg += 1
print(neg * (n - neg) + neg, n * (n + 1) // 2 - neg * (n - neg) - neg)


n = int(input())
lst = [int(i) for i in input().split()]
(neg, pos, cur) = (0, 1, 1)
for elem in lst:
	if elem < 0:
		cur *= -1
	if cur < 0:
		neg += 1
	else:
		pos += 1
print(neg * pos, neg * (neg - 1) // 2 + pos * (pos - 1) // 2)


from sys import stdin, stdout
nmbr = lambda : int(input())
lst = lambda : list(map(int, input().split()))
for _ in range(1):
	n = nmbr()
	a = lst()
	dp = [[0 for i in range(2)] for _ in range(n)]
	if a[0] < 0:
		dp[0][1] = 1
	else:
		dp[0][0] = 1
	for i in range(1, n):
		if a[i] > 0:
			dp[i][0] = dp[i - 1][0] + 1
			dp[i][1] = dp[i - 1][1]
		else:
			dp[i][0] = dp[i - 1][1]
			dp[i][1] = dp[i - 1][0] + 1
	pos = neg = 0
	for i in range(n):
		pos += dp[i][0]
		neg += dp[i][1]
	print(neg, pos)


n = int(input())
arr = input().split()
count = 0
even = 0
odd = 0
flag = 1
for i in range(n):
	if int(arr[i]) > 0:
		if flag == 1:
			even += 1
			count += even
		elif flag == -1:
			odd += 1
			count += odd
	else:
		if flag == 1:
			even += 1
			count += odd
		elif flag == -1:
			odd += 1
			count += even
		flag *= -1
total = int(n * (n + 1) / 2)
print(total - count, count)


n = int(input())
aa = list(map(int, input().split()))
pos = 1
neg = 0
p = 1
for a in aa:
	if a < 0:
		p *= -1
	if p > 0:
		pos += 1
	else:
		neg += 1
print(f'{pos * neg} {int(n * (n + 1) / 2 - pos * neg)}')


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return input().strip()

def grid(r, c):
	return [lint() for i in range(r)]
from collections import defaultdict, Counter
import math
import heapq
from heapq import heappop, heappush
import bisect
from itertools import groupby

def gcd(a, b):
	while b:
		a %= b
		tmp = a
		a = b
		b = tmp
	return a

def lcm(a, b):
	return a / gcd(a, b) * b

def check_prime(n):
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def Bs(a, x):
	i = 0
	j = 0
	left = 0
	right = len(a)
	flag = False
	while left < right:
		mi = (left + right) // 2
		if a[mi] <= x:
			left = mi + 1
			i += 1
		else:
			right = mi
			j += 1
	if left > 0 and a[left - 1] == x:
		return (i - 1, j)
	else:
		return (-1, -1)

def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res
n = I()
s = lint()
p = [0] * (n + 1)
m = [0] * (n + 1)
ns = 0
ps = 0
for i in range(1, n + 1):
	if s[i - 1] < 0:
		m[i] = p[i - 1] + 1
		p[i] = m[i - 1]
	else:
		p[i] = p[i - 1] + 1
		m[i] = m[i - 1]
	ps += p[i]
	ns += m[i]
print(ns, ps)


n = int(input())
data = []
data = list(map(int, input().strip().split()))
cnt1 = 0
cnt2 = 0
ansP = 0
bal = 0
for i in range(n):
	if bal % 2 == 0:
		cnt1 += 1
	else:
		cnt2 += 1
	if data[i] < 0:
		bal += 1
	if bal % 2 == 0:
		ansP += cnt1
	else:
		ansP += cnt2
ansN = int(n * (n + 1) / 2 - ansP)
print('%d %d' % (ansN, ansP))


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
int(input())
a = list(map(int, input().split()))
n = 0
p = 0
cntp = 0
cntn = 0
for i in a:
	if i < 0:
		(cntn, cntp) = (cntp, cntn)
		cntn += 1
	else:
		cntp += 1
	n += cntn
	p += cntp
print(n, p)


n = int(input())
a = list(map(int, input().split()))
dp = [[0 for i in range(2)] for i in range(n)]
s1 = 0
s2 = 0
if a[0] > 0:
	dp[0][0] += 1
else:
	dp[0][1] += 1
s1 += dp[0][1]
s2 += dp[0][0]
for i in range(1, n):
	if a[i] > 0:
		dp[i][0] = dp[i - 1][0] + 1
		dp[i][1] = dp[i - 1][1]
	else:
		dp[i][0] = dp[i - 1][1]
		dp[i][1] = dp[i - 1][0] + 1
	s1 += dp[i][1]
	s2 += dp[i][0]
print(s1, s2)


import math as mt
import sys, string
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
n = I()
l = L()
neg = 0
c1 = 0
c2 = 0
ans = 0
for i in range(n):
	if neg % 2 == 0:
		c1 += 1
	if neg % 2 == 1:
		c2 += 1
	if l[i] < 0:
		neg += 1
	if neg % 2 == 0:
		ans += c1
	else:
		ans += c2
w = n * (n + 1) // 2
print(w - ans, ans)


n = int(input())
a = list(map(int, input().split()))
bal = -1
cnt1 = 0
cnt2 = 0
ans = 0
for i in range(n):
	if bal % 2 == 0:
		cnt1 += 1
	else:
		cnt2 += 1
	if a[i] < 0:
		bal += 1
	if bal % 2 == 0:
		ans += cnt1
	else:
		ans += cnt2
tot = n * (n + 1) // 2
print(tot - ans, ans)


n = int(input())
a = list(map(int, input().split()))
psums = [0]
for val in a:
	psums.append(psums[-1] + (val < 0))
minusCnt = plusCnt = 0
oddCnt = evenCnt = 0
for (i, val) in enumerate(psums):
	if val & 1:
		plusCnt += oddCnt
		minusCnt += evenCnt
		oddCnt += 1
	else:
		plusCnt += evenCnt
		minusCnt += oddCnt
		evenCnt += 1
print('%d %d' % (minusCnt, plusCnt))


import sys, math, queue
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)
n = int(input())
a = list(map(int, input().split()))
(m, neg, pos) = (1, 0, 1)
for ai in a:
	if ai < 0:
		m *= -1
	if m < 0:
		neg += 1
	else:
		pos += 1
pos = neg * (neg - 1) // 2 + pos * (pos - 1) // 2
print(n * (n + 1) // 2 - pos, pos)


n = int(input())
l1 = [int(_) for _ in input().split()]
n = [0]
p = [0]
for i in l1:
	if i < 0:
		n.append(p[-1] + 1)
		p.append(n[-2])
	else:
		p.append(p[-1] + 1)
		n.append(n[-1])
print(sum(n), sum(p))


import sys
from math import *
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
ls = lambda : list(input().strip())
from collections import defaultdict as df
import heapq
infinite = float('inf')
n = int(input())
l = RI()
i = 0
while i < n:
	if l[i] < 0:
		break
	i += 1
pre = []
pre.append(i)
prev = i
i += 1
while i < n:
	if l[i] < 0:
		pre.append(i - prev - 1)
		prev = i
	i += 1
pre.append(i - prev - 1)
for i in range(len(pre)):
	pre[i] += 1
m = len(pre)
ntn = [0] * m
ntn[m - 1] = pre[m - 1]
ntn[m - 2] = pre[m - 2]
i = m - 3
while i >= 0:
	ntn[i] = ntn[i + 2] + pre[i]
	i -= 1
neg = 0
for i in range(m - 1):
	neg += pre[i] * ntn[i + 1]
f = 0
for i in range(n):
	if l[i] < 0:
		f = 1
		break
if f == 0:
	neg = 0
if n == 1:
	if l[0] > 0:
		print('0 1')
	else:
		print('1 0')
else:
	print(neg, end=' ')
	pos = (n + 1) * n // 2 - neg
	print(pos)


n = int(input())
m = [0] * (n + 1)
arr = list(map(int, input().split()))
for i in range(n):
	if arr[i] < 0:
		m[i + 1] = i - m[i] + 1
	else:
		m[i + 1] = m[i]
d = sum(m)
print(d, n * (n + 1) // 2 - d)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
vals = list(map(int, input().split()))
parity = []
sum1 = 0
for s in range(n):
	if vals[s] < 0:
		sum1 += 1
	else:
		sum1 += 0
	parity.append(sum1)
sufsum = []
odds = 0
evens = 0
for s in range(n - 1, -1, -1):
	if parity[s] % 2 == 0:
		evens += 1
	else:
		odds += 1
	sufsum.append((evens, odds))
sufsum.reverse()
pos = 0
neg = 0
for s in range(n):
	if s < n - 1:
		cur = parity[s]
		a1 = sufsum[s + 1]
		if cur % 2 == 0:
			pos += 1
			neg += a1[1]
			pos += a1[0]
		else:
			neg += 1
			neg += a1[0]
			pos += a1[1]
	elif parity[s] % 2 == 0:
		pos += 1
	else:
		neg += 1
print(neg, pos)


N = int(input())
a = list(map(int, input().split()))
neg = False
curPos = 0
hist = [0, 0]
ans = 0
for i in range(N):
	if a[i] > 0:
		curPos += 1
		ans += curPos
		if neg:
			ans += hist[1]
		else:
			ans += hist[0]
	else:
		neg = not neg
		if neg:
			hist[0] += curPos + 1
			ans += hist[1]
		else:
			hist[1] += curPos + 1
			ans += hist[0]
		curPos = 0
print(N * (N + 1) // 2 - ans, ans)


n = int(input())
ai = list(map(int, input().split()))
ai2 = [[0] * n for i in range(2)]
ai2[ai[0] < 0][0] = 1
for i in range(1, n):
	if ai[i] < 0:
		ai2[0][i] = ai2[1][i - 1]
		ai2[1][i] = ai2[0][i - 1] + 1
	else:
		ai2[0][i] = ai2[0][i - 1] + 1
		ai2[1][i] = ai2[1][i - 1]
print(sum(ai2[1]), sum(ai2[0]))


n = int(input())
L = [int(i) for i in input().split()]
sn = 0
sp = 0
if L[0] < 0:
	G = [[1, 1, 1]]
	sn += 1
else:
	G = [[0, 2, 0]]
	sp += 1
for i in range(1, n):
	H = G[i - 1][:]
	if L[i] < 0:
		H[0] += 1
		if H[0] % 2 == 0:
			sp += H[1]
			sn += H[2]
			H[1] += 1
		else:
			sp += H[2]
			sn += H[1]
			H[2] += 1
	elif H[0] % 2 == 0:
		sp += H[1]
		sn += H[2]
		H[1] += 1
	else:
		sp += H[2]
		sn += H[1]
		H[2] += 1
	G.append(H)
print(sn, sp)


from sys import stdin
n = int(stdin.readline().strip())
s = list(map(int, stdin.readline().strip().split()))
z = 0
o = 0
flag = True
ans = 0

def sum(x):
	return x * (x + 1) // 2
for i in range(n - 1, -1, -1):
	if s[i] > 0:
		z += 1
		ans += z
	else:
		aux = o
		o = z
		z = aux
		o += 1
		ans += z
print(sum(n) - ans, ans)


n = int(input())
a = list(map(int, input().split()))
b = 0
(c1, c2) = (0, 0)
(po, ne) = (0, 0)
for i in range(n):
	if b % 2 == 0:
		c1 += 1
	else:
		c2 += 1
	if a[i] < 0:
		b += 1
	if b % 2 == 0:
		po += c1
	else:
		po += c2
ne = n * (n + 1) // 2 - po
print(ne, po)


n = int(input())
num = 1
a = list(map(int, input().split()))
numd = 0
t = 1
s = 0
for i in a:
	if i < 0:
		t *= -1
	if t == 1:
		num += 1
	else:
		numd += 1
s = num * numd
print(s, n * (n + 1) // 2 - s)


import sys
from collections import defaultdict
input = lambda : sys.stdin.readline().rstrip()
n = int(input())
arr = list(map(int, input().split()))
ans = [0, 0]
dp = [0, 0]
for i in arr:
	if i > 0:
		a = dp[0] + 1
		b = dp[1]
	else:
		a = dp[1]
		b = dp[0] + 1
	dp = [a, b]
	ans[0] += a
	ans[1] += b
print(*ans[::-1])


def solve(n, ar):
	ans_p = 0
	ans_n = 0
	pos = 0
	neg = 0
	for i in range(n):
		if ar[i] > 0:
			ans_p += 1
		else:
			ans_n += 1
	if ar[0] > 0:
		flag = True
	else:
		flag = False
	for i in range(1, n):
		if flag is True:
			if ar[i] > 0:
				pos += 1
			else:
				neg += 1
				flag = False
		elif ar[i] > 0:
			neg += 1
		else:
			pos += 1
			flag = True
	dp = [[0] * 2 for _ in range(n)]
	dp[0][0] = neg
	dp[0][1] = pos
	(neg, pos) = (0, 0)
	for i in range(1, n):
		if ar[i - 1] > 0 and ar[i] < 0:
			dp[i][0] = max(0, dp[i - 1][0] - 1)
			dp[i][1] = dp[i - 1][1]
		elif ar[i - 1] < 0 and ar[i] > 0:
			dp[i][0] = dp[i - 1][1]
			dp[i][1] = max(dp[i - 1][0] - 1, 0)
		elif ar[i - 1] < 0 and ar[i] < 0:
			dp[i][0] = max(0, dp[i - 1][1] - 1)
			dp[i][1] = dp[i - 1][0]
		else:
			dp[i][0] = dp[i - 1][0]
			dp[i][1] = max(dp[i - 1][1] - 1, 0)
	for i in range(n):
		neg += dp[i][0]
		pos += dp[i][1]
	ans_n += neg
	ans_p += pos
	print(ans_n, ans_p)
	return
n = int(input())
ar = list(map(int, input().split()))
solve(n, ar)


n = int(input())
l = list(map(int, input().split()))
for i in range(n):
	if l[i] < 0:
		l[i] = -1
	else:
		l[i] = 1
cump = []
cump.append(1)
c = 1
for i in l:
	cump.append(c * (i // abs(i)))
	c = c * (i // abs(i))
ct1 = 0
ct2 = 0
lis1 = [0] * (n + 1)
lis2 = [0] * (n + 1)
for i in range(n, -1, -1):
	lis1[i] = ct1
	lis2[i] = ct2
	if cump[i] == -1:
		ct1 += 1
	else:
		ct2 += 1
count = 0
for i in range(n + 1):
	if cump[i] == 1:
		count += lis1[i]
	else:
		count += lis2[i]
print(count, n * n + n - n * (n + 1) // 2 - count)


def main():
	n = int(input())
	prod = 1
	pos = 0
	sign = 1
	pos_ans = 0
	neg = 0
	arr = list(map(int, input().split()))
	for i in arr:
		if i > 0:
			sign *= 1
		else:
			sign *= -1
		if sign > 0:
			pos_ans += pos + 1
			pos += 1
		else:
			pos_ans += neg
			neg += 1
	total = n * (n + 1) // 2
	neg_ans = total - pos_ans
	print(neg_ans, pos_ans)
main()


n = int(input())
l = list(map(int, input().split()))
(x, y) = (0, 0)
(s, ka) = (0, 0)
for i in range(n):
	if ka % 2 == 0:
		x = x + 1
	if ka % 2 == 1:
		y += 1
	if l[i] < 0:
		ka += 1
	if ka % 2 == 0:
		s = s + x
	else:
		s += y
xx = n * (n + 1) // 2
print(xx - s, s)


n = int(input())
A = [int(a) for a in input().split()]
for i in range(n):
	if A[i] > 0:
		A[i] = 1
	else:
		A[i] = -1
pre = [0] * n
pre[0] = A[0]
for i in range(1, n):
	pre[i] = pre[i - 1] * A[i]
pos = 0
neg = 0
for i in range(n):
	if pre[i] > 0:
		pos += 1
	else:
		neg += 1
neg_subseg = pos * neg + neg
pos_subseg = n * (n + 1) // 2 - neg_subseg
print(neg_subseg, pos_subseg)


n = int(input())
lis = [int(x) for x in input().split()]
total = 0
negative_elements = 0
even_before = 0
odd_before = 0
for i in lis:
	if i < 0:
		if negative_elements % 2 == 0:
			total += odd_before
			even_before += 1
		else:
			total += even_before
			odd_before += 1
		negative_elements += 1
	elif negative_elements % 2 == 0:
		total += even_before + 1
		even_before += 1
	else:
		total += odd_before + 1
		odd_before += 1
print(n * (n + 1) // 2 - total, total)


def Solve(nums):
	pos = 0
	neg = 0
	pos_t = 0
	pos_t1 = 0
	pos_f = 0
	pos_f1 = 0
	neg_t = 0
	neg_f = 0
	flag = False
	for n in nums:
		if n > 0:
			pos += 1
			if flag:
				pos += pos_t
				pos += neg_f
				neg += pos_f1
				neg += neg_t
				pos_t += 1
			else:
				pos += pos_f
				pos += neg_t
				neg += pos_t1
				neg += neg_f
				pos_f += 1
		else:
			flag = not flag
			pos_f1 = pos_f
			pos_t1 = pos_t
			neg += 1
			if flag:
				neg += neg_t
				neg += pos_f
				pos += neg_f
				pos += pos_t
				neg_t += 1
			else:
				neg += neg_f
				neg += pos_t
				pos += neg_t
				pos += pos_f
				neg_f += 1
	return (neg, pos)

def Wrap(str):
	inp = map(int, str.split(' '))
	return Solve(inp)

def Check(a, b):
	if a == b:
		print('yes')
	else:
		print("no, '{}' instead of '{}'".format(a, b))
c = input()
(a, b) = Solve(map(int, input().split(' ')))
print('{} {}'.format(a, b))


import sys
from sys import stdin

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	sumNeg = [0] * (n + 2)
	sumNeg[0] = 0
	for i in range(1, n + 1):
		sumNeg[i] = (sumNeg[i - 1] + (1 if a[i - 1] < 0 else 0)) % 2
	cntNeg = 0
	cntPos = 0
	cnt = [0] * 2
	cnt[0] += 1
	for i in range(1, n + 1):
		cntNeg += cnt[sumNeg[i] ^ 1]
		cntPos += cnt[sumNeg[i]]
		cnt[sumNeg[i]] += 1
	print(cntNeg, cntPos)

def main():
	solve()
main()


n = int(input())
a = list(map(int, input().split()))
c = cnt1 = cnt2 = 0
ansp = 0
for i in range(n):
	if c % 2 == 0:
		cnt1 += 1
	else:
		cnt2 += 1
	if a[i] < 0:
		c += 1
	if c % 2 == 0:
		ansp += cnt1
	else:
		ansp += cnt2
x = n * (n + 1) // 2
print(x - ansp, ansp)


from bisect import insort as ins
from bisect import bisect_left as bl
from collections import defaultdict as dd

def count(ar, n):
	temp = [1, 0]
	result = 0
	val = 0
	for i in range(n):
		val = ((val + ar[i]) % 2 + 2) % 2
		temp[val] += 1
	result = temp[0] * temp[1]
	return result
n = int(input())
a = [int(i) for i in input().split()]
l = []
for i in a:
	if i < 0:
		l.append(1)
	else:
		l.append(0)
tot = n * (n + 1) // 2
x = count(l, n)
print(x, tot - x)


size = int(input())
arr = list(map(int, input().split()))
t_nve = 0
t_pve = 0
nve = 0
pve = 0
sign = 1
for item in arr:
	sign = sign * (item / abs(item))
	if sign == -1:
		nve += 1
	else:
		pve += 1
t_nve += nve
t_pve += pve
for i in range(0, size - 1):
	if arr[i] > 0:
		pve -= 1
	else:
		nve -= 1
		temp = nve
		nve = pve
		pve = temp
	t_pve += pve
	t_nve += nve
print(f'{t_nve} {t_pve}')


import sys
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
cnt1 = 0
cnt2 = 0
ansP = 0
bal = 0
for i in range(n):
	if bal % 2 == 0:
		cnt1 += 1
	else:
		cnt2 += 1
	if arr[i] < 0:
		bal += 1
	if bal % 2 == 0:
		ansP += cnt1
	else:
		ansP += cnt2
print(n * (n + 1) // 2 - ansP, ansP)


n = int(input())
lis = list(map(int, input().split()))
l = []
for i in range(n):
	if lis[i] < 0:
		l.append(i)
if len(l) == 0:
	print(0, n * (n + 1) // 2)
	exit()
if len(l) == 1:
	x = (n - l[0]) * (l[0] + 1)
	print(x, n * (n + 1) // 2 - x)
	exit()
dp = [0] * len(l)
dp[-1] = n - l[-1]
dp[-2] = l[-1] - l[-2]
for i in range(len(dp) - 3, -1, -1):
	dp[i] = dp[i + 2] + l[i + 1] - l[i]
x = 0
j = 0
for i in range(n):
	if i <= l[j]:
		x += dp[j]
	else:
		j += 1
		if j == len(l):
			break
		x += dp[j]
print(x, n * (n + 1) // 2 - x)


n = int(input())
nums = list(map(int, input().split()))
pos = [0]
neg = [0]
for a in nums:
	if a > 0:
		pos.append(pos[len(pos) - 1])
		neg.append(neg[len(neg) - 1])
		pos[len(pos) - 1] += 1
	else:
		neg.append(pos[len(pos) - 1])
		pos.append(neg[len(neg) - 2])
		neg[len(neg) - 1] += 1
print(sum(neg), sum(pos))


def sequence(arr, n):
	pos = [0 for i in range(n)]
	neg = [0 for i in range(n)]
	for i in range(n):
		if arr[i] > 0:
			pos[i] = pos[i - 1] + 1
			neg[i] = neg[i - 1]
		else:
			pos[i] = neg[i - 1]
			neg[i] = pos[i - 1] + 1
	a = sum(pos)
	b = sum(neg)
	print('{} {}'.format(b, a))
n = int(input())
arr = [int(i) for i in input().split(' ')]
sequence(arr, n)


n = int(input())
a = [*map(int, input().split())]
b = [int(i < 0) for i in a]
t = [1, 0]
v = 0
for i in range(n):
	v = ((v + b[i]) % 2 + 2) % 2
	t[v] += 1
r = t[0] * t[1]
print(r, n * (n + 1) // 2 - r)


n = int(input())
a = list(map(int, input().split()))
for j in range(n):
	if a[j] > 0:
		a[j] = 1
	elif a[j] < 0:
		a[j] = -1
arr = [0 for j in range(n)]
arr[0] = a[0]
if a[0] > 0:
	num1 = 1
	num2 = 0
elif a[0] < 0:
	num2 = 1
	num1 = 0
for j in range(1, n):
	arr[j] = arr[j - 1] * a[j]
	if arr[j] > 0:
		num1 += 1
	else:
		num2 += 1
sum1 = num1
sum2 = num2
for j in range(n):
	if arr[j] > 0:
		num1 = num1 - 1
		num4 = num2
		sum1 += num1
		sum2 += num4
	elif arr[j] < 0:
		num2 = num2 - 1
		(num3, num4) = (num2, num1)
		sum1 += num3
		sum2 += num4
print(sum2, sum1)


m = int(input())
l = [int(x) for x in input().split(' ')]
p = 1
n = 0
ans = int
for i in range(m):
	if l[i] > 0:
		l[i] = 1
	else:
		l[i] = -1
	if i > 0:
		l[i] *= l[i - 1]
	if l[i] == 1:
		p += 1
	else:
		n += 1
ans = m * (m + 1) // 2
print(p * n, ' ', ans - p * n)


n = int(input())
c = [1, 0]
s = 0
a = 0
for x in map(int, input().split()):
	if x < 0:
		s = 1 - s
	a += c[s]
	c[s] += 1
print(n * (n + 1) // 2 - a, a)


x = {'pos': [0] * 200005, 'neg': [0] * 200005}
(neg, pos) = (0, 0)
n = int(input())
l = [int(x) for x in input().split()]
for i in range(n):
	if i == 0:
		x['neg'][i] = l[i] < 0
		x['pos'][i] = l[i] >= 0
	elif l[i] < 0:
		x['pos'][i] = x['neg'][i - 1]
		x['neg'][i] = +x['pos'][i - 1] + 1
	else:
		x['pos'][i] = x['pos'][i - 1] + 1
		x['neg'][i] = x['neg'][i - 1]
	neg += x['neg'][i]
	pos += x['pos'][i]
print(neg, pos)


ans = 0
sumOdd = 0
sumEven = 0
flag = 0
sum0 = 0
n = int(input())
s = input().split(' ')
for i in s:
	x = 0 if int(i) > 0 else 1
	if x == 1:
		flag ^= 1
		if flag:
			sumOdd += 1
			ans += sumOdd
		else:
			sumEven += 1
			ans += sumEven
	elif flag:
		ans += sumOdd
		sumEven += 1
	else:
		ans += sumEven
		sumOdd += 1
print(ans, int(n * (n + 1) / 2 - ans))


def fun(p):
	m = len(p)
	w = [1] * (m + 1)
	for i in range(0, m):
		if p[i] > 0:
			w[i + 1] = w[i]
		else:
			w[i + 1] = -w[i]
	s = 0
	for i in range(1, m + 1):
		if w[i] < 0:
			s += 1
	return s * (m + 1 - s)
n = int(input())
p = [int(x) for x in input().split()]
print(fun(p), int(n * (n + 1) / 2) - fun(p))


import os
import sys
from math import *
from collections import *
from heapq import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
a = array()
pos = 1
neg = 0
prod = 1
ans_negs = 0
ans_pos = 0
for i in a:
	if i < 0:
		prod *= -1
	if prod > 0:
		ans_negs += neg
		ans_pos += pos
		pos += 1
	else:
		ans_negs += pos
		ans_pos += neg
		neg += 1
print(ans_negs, ans_pos)


n = int(input())
arr = list(map(int, input().split()))
neg = []
i = 1
while i < n + 1:
	if arr[i - 1] < 0:
		neg.append(i)
	i += 1
a = 0
count = 0
m = len(neg)
if m == 0:
	print('0 ' + str((n * n + n) // 2))
else:
	i = 0
	b = 0
	c = 0
	if m > 1:
		while i < m - 1:
			if i % 2 == 1:
				count += (c + neg[i] - a) * (neg[i + 1] - neg[i])
				c += neg[i] - a
			else:
				count += (b + neg[i] - a) * (neg[i + 1] - neg[i])
				b += neg[i] - a
			a = neg[i]
			i += 1
	if m % 2 == 1:
		count += (b + neg[-1] - a) * (n + 1 - neg[-1])
	else:
		count += (c + neg[-1] - a) * (n + 1 - neg[-1])
	print(str(count) + ' ' + str((n * n + n) // 2 - count))


def ceil(n, k):
	if n % k == 0:
		return n // k
	return n // k + 1
for _ in range(1):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	for i in a:
		if i > 0:
			l.append(0)
		else:
			l.append(1)
	a = l
	p = []
	prec = [0] * n
	i = 0
	c = 0
	f = 1
	while i < n:
		if a[i]:
			p.append(1)
			prec[i] = f
			f *= -1
			c += 1
			i += 1
		else:
			app = 2
			if c & 1:
				app = 3
			j = i
			while j < n and a[j] == 0:
				p.append(app)
				j += 1
			i = j
	pre2 = [0] * n
	pre3 = [0] * n
	pre1 = [0] * n
	if p[n - 1] == 2:
		pre2[n - 1] = 1
	elif p[n - 1] == 3:
		pre3[n - 1] = 1
	else:
		pre1[n - 1] = 1
	for i in range(n - 2, -1, -1):
		if p[i] == 2:
			pre2[i] = pre2[i + 1] + 1
			pre3[i] = pre3[i + 1]
			pre1[i] = pre1[i + 1]
		elif p[i] == 3:
			pre3[i] = pre3[i + 1] + 1
			pre2[i] = pre2[i + 1]
			pre1[i] = pre1[i + 1]
		else:
			pre1[i] = pre1[i + 1] + 1
			pre2[i] = pre2[i + 1]
			pre3[i] = pre3[i + 1]
	totp = 0
	totn = 0
	for i in range(n):
		if a[i] == 0:
			front = 0
			if p[i] == 2:
				front = pre2[i] + pre1[i] // 2
			else:
				front = pre3[i] + pre1[i] // 2
			totp += front
			totn += n - i - front
		else:
			front = ceil(pre1[i], 2)
			totn += front
			ee = front
			front = 0
			if prec[i] == 1:
				front = pre3[i]
			else:
				front = pre2[i]
			totn += front
			totp += n - i - (front + ee)
	print(totn, totp)


n = int(input())
arr = list(map(int, input().split()))
neg_cnt = 0
pos_cnt = 0
neg = 0
pos = 0
for i in arr:
	if i > 0:
		pos_cnt += 1
	if i < 0:
		temp = pos_cnt
		pos_cnt = neg_cnt
		neg_cnt = temp + 1
	pos += pos_cnt
	neg += neg_cnt
print(neg, pos)


h = int(input())
num = [int(x) for x in input().split()]
cont_pos = [] * len(num)
cont_neg = [] * len(num)
aux = 0
pos = 0
neg = 0
if num[0] > 0:
	cont_pos.append(1)
	cont_neg.append(0)
	pos += 1
else:
	cont_pos.append(0)
	cont_neg.append(1)
for i in range(1, h):
	if num[i] > 0:
		cont_pos.append(cont_pos[i - 1] + 1)
		cont_neg.append(cont_neg[i - 1])
	if num[i] < 0:
		cont_neg.append(cont_neg[i - 1])
		cont_pos.append(cont_pos[i - 1])
		aux = cont_pos[i]
		cont_pos[i] = cont_neg[i]
		cont_neg[i] = aux + 1
print(sum(cont_neg), sum(cont_pos))


n = int(input())
arr = list(map(int, input().rsplit()))
pos = 0
neg = 0
endPos = 0
endNeg = 0
for i in range(n):
	num = arr[i]
	if num < 0:
		tendPos = endNeg
		pos += tendPos
		tendNeg = 1 + endPos
		neg += tendNeg
		endPos = tendPos
		endNeg = tendNeg
	else:
		tendPos = 1 + endPos
		pos += tendPos
		tendNeg = endNeg
		neg += tendNeg
		endPos = tendPos
		endNeg = tendNeg
print(str(neg) + ' ' + str(pos))


def get_int():
	return int(input())

def sgn(x):
	return 1 if x > 0 else -1
n = get_int()
numbers = list(map(int, input().split(' ')))
prev_negatives = prev_positives = positives = negatives = 0
sign = 1
for i in range(n):
	current_sign = sgn(numbers[i])
	if current_sign < 0:
		temp = prev_negatives
		prev_negatives = prev_positives
		prev_positives = temp
	positives += prev_positives
	negatives += prev_negatives
	if current_sign > 0:
		positives += 1
	else:
		negatives += 1
	sign = sign * current_sign
	if current_sign == 1:
		prev_positives += 1
	else:
		prev_negatives += 1
print('{0} {1}'.format(negatives, positives))


import sys
from collections import defaultdict as dd
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
n = ri(1)
a = ri()

def count(ar, n):
	temp = [1, 0]
	result = 0
	val = 0
	for i in range(n):
		val = ((val + ar[i]) % 2 + 2) % 2
		temp[val] += 1
	result = temp[0] * temp[1]
	return result
k = []
for i in a:
	if i > 0:
		k.append(0)
	else:
		k.append(1)
now = count(k, n)
total = n * (n + 1) // 2
print(now, total - now)


n = int(input())
arr = list(map(int, input().strip().split()))
pos = [0 for i in range(n + 1)]
neg = [0 for i in range(n + 1)]
for i in range(n):
	if arr[i] > 0:
		pos[i + 1] = pos[i] + 1
		neg[i + 1] = neg[i]
	else:
		pos[i + 1] = neg[i]
		neg[i + 1] = pos[i] + 1
print(sum(neg), sum(pos))


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def sumDigits(no):
	return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10))
MOD = 1000000007
PMOD = 998244353
N = 10 ** 5
T = 1
for _ in range(T):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	dp = []
	for i in range(n):
		dp.append([0, 0])
	if a[0] > 0:
		dp[0][0] = 1
	else:
		dp[0][1] = 1
	for i in range(1, n):
		if a[i] > 0:
			dp[i][0] = dp[i - 1][0] + 1
			dp[i][1] = dp[i - 1][1]
		else:
			dp[i][0] = dp[i - 1][1]
			dp[i][1] = dp[i - 1][0] + 1
	neg = 0
	pos = 0
	for i in range(n):
		neg += dp[i][1]
		pos += dp[i][0]
	print(neg, pos)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
import itertools

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	n = Int()
	a = List()
	mul = 1
	neg = 0
	pos = 1
	for i in range(n):
		if a[i] < 0:
			mul = mul * -1
		else:
			mul = mul * 1
		if mul < 0:
			neg += 1
		else:
			pos += 1
	print(neg * pos, n * (n + 1) // 2 - neg * pos)
solution()


n = int(input())
L = list(map(int, input().split()))
tot = n * (n + 1) / 2
M = [0] * n
if L[0] > 0:
	M[0] += 1
for i in range(1, n):
	if L[i] > 0:
		M[i] = M[i - 1] + 1
	else:
		M[i] = i - M[i - 1]
s = 0
for i in range(0, n):
	s += M[i]
N = [int(tot) - s, s]
print(*N)


n = int(input())
a = list(map(int, input().split()))
a_n = [0]
for i in range(n):
	if a[i] < 0:
		a_n.append(a_n[i] + 1)
	else:
		a_n.append(a_n[i])
odd = [0]
even = [0]
for i in range(1, n + 1):
	if a_n[i] % 2 == 1:
		odd.append(odd[-1] + 1)
		even.append(even[-1])
	else:
		odd.append(odd[-1])
		even.append(even[-1] + 1)
ans = 0
for i in range(n):
	if a[i] > 0:
		if a_n[i + 1] % 2 == 0:
			ans += even[n] - even[i]
		else:
			ans += odd[n] - odd[i]
	elif a_n[i + 1] % 2 == 0:
		ans += odd[n] - odd[i]
	else:
		ans += even[n] - even[i]
print(n * (n + 1) // 2 - ans, ans)


import sys
n = int(sys.stdin.readline().strip())
a = list(map(int, sys.stdin.readline().strip().split()))
v1 = 0
v2 = 0
p = 0
m = 0
for i in range(0, n):
	if a[i] == 0:
		p = 0
		m = 0
	if a[i] > 0:
		p = p + 1
	if a[i] < 0:
		(p, m) = (m, p)
		m = m + 1
	v1 = v1 + p
	v2 = v2 + m
print(str(v2) + ' ' + str(v1))


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 10 ** 5 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b):
	return abs(a[0] - b[0]) + abs(b[1] - a[1])

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def eld(x, y):
	a = y[0] - x[0]
	b = x[1] - y[1]
	return (a * a + b * b) ** 0.5

def lgcd(a):
	g = a[0]
	for i in range(1, len(a)):
		g = math.gcd(g, a[i])
	return g

def ms(a):
	msf = -MAX
	meh = 0
	st = en = be = 0
	for i in range(len(a)):
		meh += a[i]
		if msf < meh:
			msf = meh
			st = be
			en = i
		if meh < 0:
			meh = 0
			be = i + 1
	return (msf, st, en)

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()

def fac(n):
	ans = 1
	for i in range(1, n + 1):
		ans *= i
		ans %= MOD
	return ans

def fun(a, n, m):
	x = [0] * n
	ans = 0
	mp = dict()
	x[0] = a[0]
	for i in range(1, n):
		x[i] = x[i - 1] ^ a[i]
	for i in range(n):
		tmp = m ^ x[i]
		if tmp in mp.keys():
			ans += mp[tmp]
		if x[i] == m:
			ans += 1
		mp[x[i]] = mp.get(x[i], 0) + 1
	return ans
n = int(input())
a = arrIN()
x = []
for i in a:
	if i > 0:
		x.append(1)
	else:
		x.append(-1)
ans = fun(x, n, -1) + fun(x, n, -2)
print(ans, n * (n + 1) // 2 - ans)


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
(ans_pos, ans_neg) = (0, 0)
(prev_pos, prev_neg) = (0, 0)
for ai in a:
	if ai > 0:
		next_pos = prev_pos + 1
		next_neg = prev_neg
	elif ai < 0:
		next_pos = prev_neg
		next_neg = prev_pos + 1
	ans_pos += next_pos
	ans_neg += next_neg
	(prev_pos, prev_neg) = (next_pos, next_neg)
print(ans_neg, ans_pos)


N = int(input())
nums = list(map(int, input().split()))
tot = (1, 0) if nums[0] < 0 else (0, 1)
runTot = tot
for i in range(1, N):
	if nums[i] > 0:
		tot = (tot[0], tot[1] + 1)
	else:
		tot = (tot[1] + 1, tot[0])
	runTot = (runTot[0] + tot[0], runTot[1] + tot[1])
print(runTot[0], runTot[1])


n1 = int(input())
a = [int(x) for x in input().split()]
n = 0
p = 0
pp = 0
np = 0
pro = 1
l = [[0, 0] for i in range(n1)]
if a[0] > 0:
	l[0][0] = 1
else:
	l[0][1] = 1
for i in range(1, n1):
	if a[i] > 0:
		l[i][0] = l[i - 1][0] + 1
		l[i][1] = l[i - 1][1]
	else:
		l[i][1] = l[i - 1][0] + 1
		l[i][0] = l[i - 1][1]
for i in range(n1):
	n += l[i][1]
	p += l[i][0]
print(n, p)


n = int(input())
list = list(map(int, input().split()))
pos = 1
neg = 0
sign = 1
for i in list:
	if i < 0:
		sign *= -1
	if sign > 0:
		pos += 1
	else:
		neg += 1
posFinal = pos * neg
negFinal = n * (n + 1) // 2 - posFinal
print(pos * neg, n * (n + 1) // 2 - pos * neg)


n = int(input())
a = input().split()
for i in range(n):
	a[i] = int(a[i])
b = [0]
count = 0
for i in range(n):
	if a[i] < 0:
		count += 1
	b.append(count)
c1 = 0
c2 = 0
ans = 0
for i in range(n + 1):
	if b[i] % 2 == 0:
		ans += c1
		c1 += 1
	else:
		ans += c2
		c2 += 1
print(n * (n + 1) // 2 - ans, ans)


n = int(input())
a = list(map(int, input().split()))
positive = [0]
negative = [0]
sm = 0
for x in a:
	if x > 0:
		positive.append(positive[-1] + 1)
		negative.append(negative[-1])
	else:
		positive.append(negative[-1])
		negative.append(positive[-2] + 1)
	sm += positive[-1]
print(n * (n + 1) // 2 - sm, sm)


n = int(input())
a = [int(item) for item in input().split()]
a.append(-1)
even = 0
odd = 0
b = []
cnt = 0
is_even = True
for item in a:
	if item < 0:
		cnt += 1
		if is_even:
			even += cnt
			is_even = False
		else:
			odd += cnt
			is_even = True
		cnt = 0
	else:
		cnt += 1
ans = 0
ans += even * (even - 1) // 2
ans += odd * (odd - 1) // 2
total = (n + 1) * n // 2
print(total - ans, ans)


input()
ns = [int(n) for n in input().split()]
accum_negs = 0
(negatives, positives) = (0, 0)
for n in ns:
	if n < 0:
		accum_negs += 1
	if accum_negs % 2 != 0:
		negatives += 1
	else:
		positives += 1
total_positives = positives * (positives - 1) / 2 + negatives * (negatives - 1) / 2 + positives
total_negatives = len(ns) * (len(ns) + 1) / 2 - total_positives
print(int(total_negatives), int(total_positives))


N = int(input())
arr = input().split(' ')
a = []
for i in range(N):
	a.append(int(arr[i]))
p = [0 for i in range(N)]
n = [0 for i in range(N)]
if a[0] > 0:
	p[0] = 1
	n[0] = 0
else:
	p[0] = 0
	n[0] = 1
for i in range(1, N):
	if a[i] > 0:
		p[i] += 1
		p[i] = p[i] + p[i - 1]
		n[i] = n[i] + n[i - 1]
	else:
		n[i] += 1
		p[i] = p[i] + n[i - 1]
		n[i] = n[i] + p[i - 1]
print(sum(n), sum(p))


n = int(input())
(anspos, ansneg) = (0, 0)
(pos, neg) = (0, 0)
for i in input().split(' '):
	i = int(i)
	if i < 0:
		(pos, neg) = (neg, pos + 1)
	else:
		(pos, neg) = (pos + 1, neg)
	anspos += pos
	ansneg += neg
print(ansneg, anspos)


n = int(input())
a = [int(i) for i in input().split()]
pos = [0 for _ in range(n)]
neg = [0 for _ in range(n)]
pos_sum = 0
neg_sum = 0
for i in range(n):
	if a[i] < 0:
		neg[i] = 1 + (pos[i - 1] if i - 1 >= 0 else 0)
		pos[i] = neg[i - 1] if i - 1 >= 0 else 0
	else:
		neg[i] = neg[i - 1] if i - 1 >= 0 else 0
		pos[i] = 1 + (pos[i - 1] if i - 1 >= 0 else 0)
	neg_sum += neg[i]
	pos_sum += pos[i]
print(neg_sum, pos_sum)


nn = int(input())
a = list(map(int, input().split()))
b = a[::-1]
p = 0
n = 0
c = []
if b[0] < 0:
	n += 1
else:
	p += 1
c.append([p, n])
for i in range(1, nn):
	if b[i] > 0:
		c.append([c[-1][0] + 1, c[-1][1]])
	else:
		c.append([c[-1][1], c[-1][0] + 1])
p = n = 0
for i in c:
	p += i[0]
	n += i[1]
print(n, p)


n = int(input())
a = list(map(int, input().split()))
(pos, neg) = (0, 0)
if a[0] > 0:
	pos += 1
else:
	neg += 1
(pos, neg) = (0, 0)
(pa, na) = (pos, neg)
for i in range(0, len(a)):
	if a[i] > 0:
		pos = pos + 1
	else:
		(nn, pp) = (neg, pos)
		neg = pos + 1
		pos = nn
	pa += pos
	na += neg
print(na, pa)


n = int(input())
pos = 1
neg = 0
k = 1
l = list(map(int, input().split()))
for t in l:
	if t < 0:
		k *= -1
	if k < 0:
		neg += 1
	else:
		pos += 1
print(pos * neg, n * (n + 1) // 2 - pos * neg)


n = int(input())
nums = list(map(int, input().split()))
revmark = [0 for i in range(n)]
revcount = [[0, 0] for i in range(n)]
curr = 0
for i in range(n - 1, -1, -1):
	if nums[i] < 0:
		curr += 1
	if curr % 2:
		revmark[i] = -1
	else:
		revmark[i] = 1
count = [0, 0]
for i in range(n):
	if revmark[i] < 0:
		count[0] += 1
	else:
		count[1] += 1
	if nums[i] < 0:
		if revmark[i] < 0:
			revcount[i] = count[:]
		else:
			revcount[i] = count[::-1]
	elif revmark[i] < 0:
		revcount[i] = count[::-1]
	else:
		revcount[i] = count[:]
ans = [0, 0]
for i in range(n):
	if i == 0:
		if nums[i] > 0:
			ans[1] += 1
		else:
			ans[0] += 1
	elif nums[i] > 0:
		ans[1] += revcount[i - 1][1]
		ans[1] += 1
		ans[0] += revcount[i - 1][0]
	else:
		ans[1] += revcount[i - 1][0]
		ans[0] += 1
		ans[0] += revcount[i - 1][1]
print(*ans)


from collections import Counter
import copy
n = int(input())
arrs = list(map(int, input().split()))
arr = []
for i in arrs:
	if i < 0:
		arr += [1]
	else:
		arr += [0]
pre = [arr[0]]
for i in range(1, n):
	pre += [arr[i] ^ pre[-1]]
freq = dict()
summ = 0
freq[0] = 0
freq[1] = 0
for i in range(n):
	if pre[i] in freq:
		freq[pre[i]] += 1
	else:
		freq[pre[i]] = 1
summ += freq[0] * (freq[0] - 1) // 2 + freq[0] + freq[1] * (freq[1] - 1) // 2
print(n * (n + 1) // 2 - summ, summ)


def run():
	n = eval(input())
	nums = list(map(int, input().split()))
	pos = 0
	neg = 0
	all_pos = [0] * n
	all_neg = [0] * n
	for i in range(n - 1, -1, -1):
		num = nums[i]
		if i == n - 1:
			if num > 0:
				all_pos[i] = 1
			else:
				all_neg[i] = 1
		else:
			if num > 0:
				all_pos[i] = 1
			else:
				all_neg[i] = 1
			if nums[i] > 0:
				if nums[i + 1] > 0:
					all_pos[i] = all_pos[i] + all_pos[i + 1]
					all_neg[i] = all_neg[i] + all_neg[i + 1]
				else:
					all_pos[i] = all_pos[i] + all_pos[i + 1]
					all_neg[i] = all_neg[i] + all_neg[i + 1]
			elif nums[i + 1] > 0:
				all_pos[i] = all_pos[i] + all_neg[i + 1]
				all_neg[i] = all_neg[i] + all_pos[i + 1]
			else:
				all_pos[i] = all_pos[i] + all_neg[i + 1]
				all_neg[i] = all_neg[i] + all_pos[i + 1]
	neg = sum(all_neg)
	pos = sum(all_pos)
	print(neg, pos)
run()


n = int(input())
lis = list(map(int, input().split()))
k = 1
pos = 1
neg = 0
for i in lis:
	if i < 0:
		k *= -1
	if k < 0:
		neg += 1
	else:
		pos += 1
ne = pos * neg
print(ne, n * (n + 1) // 2 - ne)


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

def getVars():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def getStr():
	return input().strip()

def addDictList(d, key, val):
	if key not in d:
		d[key] = []
	d[key].append(val)

def addDictInt(d, key, val):
	if key not in d:
		d[key] = 0
	d[key] = val

def addDictCount(d, key):
	if key not in d:
		d[key] = 0
	d[key] += 1

def addDictSum(d, key, val):
	if key not in d:
		d[key] = 0
	d[key] += val
n = getInt()
a = getList()
d = {-1: 0, 1: 0}
k = {-1: 0, 1: 0}
for i in range(n):
	if a[i] < 0:
		temp = k[1]
		k[1] = k[-1]
		k[-1] = temp
	key = a[i] // abs(a[i])
	k[key] += 1
	d[-1] += k[-1]
	d[1] += k[1]
print(d[-1], d[1])


import sys
import math
import bisect
import heapq
from bisect import bisect_right
from sys import stdin, stdout

def get_ints_in_variables():
	return map(int, sys.stdin.readline().strip().split())

def get_int():
	return int(sys.stdin.readline())

def get_ints_in_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

def get_string():
	return sys.stdin.readline().strip()

def myceil(x, y):
	return (x + y - 1) // y

def Solution(arr, n):
	odd = 1
	even = 0
	negAns = 0
	cnt = 0
	for i in range(n):
		if arr[i] < 0:
			cnt += 1
		if cnt & 1:
			negAns += odd
			even += 1
		else:
			negAns += even
			odd += 1
	total = n * (n + 1) // 2
	print(negAns, total - negAns)

def main():
	n = get_int()
	arr = get_ints_in_list()
	Solution(arr, n)
main()


from sys import *
m = int(input())
a = list(map(int, stdin.readline().split()))
n = m * (m + 1) // 2
d = [0] * m
if a[0] > 0:
	d[0] += 1
for i in range(1, m):
	if a[i] > 0:
		d[i] += d[i - 1] + 1
	else:
		d[i] = i - d[i - 1]
p = sum(d)
n = n - p
print(n, p)


n = int(input())
y = list(map(int, input().split()))
pos = [0]
neg = [0]
s = 0
for i in y:
	if i > 0:
		pos.append(pos[-1] + 1)
		neg.append(neg[-1])
	else:
		pos.append(neg[-1])
		neg.append(pos[-2] + 1)
	s += pos[-1]
print(n * (n + 1) // 2 - s, s)


(n, a, b) = (int(input()), 0, 0)
d = {-1: 0, 1: 1}
s = 1
arr = list(map(int, input().split()))
for c in arr:
	c //= abs(c)
	s *= c
	a += d[s]
	b += d[-s]
	d[s] += 1
print(b, a)


def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
import math
n = ii()
a = li()
l = [0] * 200005
s = ans = 0
t = n * (n + 1) // 2
for i in range(n):
	if a[i] < 0:
		l[i] = 1
	(c, d) = (1, 0)
for i in range(n):
	s += l[i]
	if s % 2 != 0:
		ans += d
		d += 1
	else:
		ans += c
		c += 1
print(t - ans, ans)


import heapq, math
from collections import defaultdict, deque
import sys, os.path
if os.path.exists('C:/Users/Dhanush/Desktop/cp/input.txt'):
	sys.stdout = open('C:/Users/Dhanush/Desktop/cp/output.txt', 'w')
	sys.stdin = open('C:/Users/Dhanush/Desktop/cp/input.txt', 'r')
input = sys.stdin.readline
n = int(input())
dp = [[0 for _ in range(2)] for _ in range(n)]
l = list(map(int, input().split()))
(pos, neg) = (0, 0)
if l[0] > 0:
	dp[0][0] = 1
	pos += 1
else:
	dp[0][1] = 1
	neg += 1
for i in range(1, n):
	if l[i] > 0:
		dp[i][0] = 1 + dp[i - 1][0]
		dp[i][1] = dp[i - 1][1]
	else:
		dp[i][0] = dp[i - 1][1]
		dp[i][1] = 1 + dp[i - 1][0]
	pos += dp[i][0]
	neg += dp[i][1]
print(neg, pos)


import math
n = int(input())
a = input().split(' ')
for i in range(n):
	a[i] = int(a[i])
s = int((2 + (n - 1)) / 2 * n)
kot = 0
ch = 0
nch = 0
otv = 0
for i in range(n):
	if kot % 2 == 0:
		ch += 1
	else:
		nch += 1
	if a[i] < 0:
		kot += 1
	if kot % 2 == 0:
		otv += ch
	else:
		otv += nch
print(str(s - otv) + ' ' + str(otv))


import sys
import math
import functools
from collections import deque
sin = sys.stdin

def rint():
	return int(sin.readline())

def rstr():
	return sin.readline()[:-1]

def rints():
	return [int(x) for x in sin.readline().split()]

def rlineints(lines):
	arr = []
	for _ in range(lines):
		arr.append(int(sin.readline()))
	return arr

def rstrs():
	return [x for x in sin.readline().split()]

def rlinestrings(lines):
	arr = []
	for _ in range(lines):
		arr.append(sin.readline()[:-1])
	return arr
n = rint()
ints = rints()
neg = 0
pos = 0
negending = 0
posending = 0
for i in ints:
	if i > 0:
		posending += 1
	if i < 0:
		hold = posending
		posending = negending
		negending = hold + 1
	neg += negending
	pos += posending
print(neg, pos)


def main():
	(n, a, c, cc) = (int(input()), True, [0, 0], [0, 0])
	for s in input().split():
		a ^= s[0] == '-'
		if a:
			cc[0] += c[0]
			cc[1] += c[1] + 1
		else:
			cc[1] += c[0]
			cc[0] += c[1] + 1
		c[a] += 1
	print(*cc)
main()


n = int(input())
array = list(map(int, input().split()))
numbers = [[0, 0] for k in range(n)]
for k in range(n):
	if array[k] >= 0:
		numbers[k][0] += 1
	else:
		numbers[k][1] += 1
c1 = numbers[0][0]
c2 = numbers[0][1]
for k in range(1, n):
	if array[k] <= 0:
		numbers[k][0] += numbers[k - 1][1]
		numbers[k][1] += numbers[k - 1][0]
	else:
		numbers[k][0] += numbers[k - 1][0]
		numbers[k][1] += numbers[k - 1][1]
	c1 += numbers[k][0]
	c2 += numbers[k][1]
out = str(c2) + ' ' + str(c1)
print(out)


n = int(input())
x = list(map(int, input().split()))
(dp, dp2, r) = ([0] * 200000, [0] * 200000, [0] * 200000)
for i in range(n):
	if i == 0:
		r[0] = x[0] / abs(x[0])
		if r[0] > 0:
			dp[0] = 1
		else:
			dp2[0] = 1
	else:
		r[i] = r[i - 1] * x[i] / abs(x[i])
		if r[i] > 0:
			dp[i] = dp[i - 1] + 1
			dp2[i] = dp2[i - 1]
		else:
			dp[i] = dp[i - 1]
			dp2[i] = dp2[i - 1] + 1
(ansp, ansn) = (dp[n - 1], dp2[n - 1])
for i in range(n):
	if r[i] > 0:
		ansp += dp[n - 1] - dp[i]
		ansn += dp2[n - 1] - dp2[i]
	else:
		ansp += dp2[n - 1] - dp2[i]
		ansn += dp[n - 1] - dp[i]
print(ansn, ansp)


from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict
from bisect import bisect_left

def get_aux(arr):
	aux = []
	temp = []
	for i in range(len(arr)):
		if arr[i] > 0:
			temp.append(arr[i])
		elif arr[i] < 0:
			if len(temp) > 0:
				aux.append(temp)
				temp = []
			else:
				pass
	if len(temp) > 0:
		aux.append(temp)
	aux2 = []
	for temp in aux:
		aux2.append(len(temp))
	return aux2

def get_descrete(num):
	return num + num * (num - 1) // 2

def change(num):
	if num == 0:
		return 1
	else:
		return 0
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().split()))
negate = [0] * n
if arr[0] < 0:
	negate[0] = 1
for i in range(1, n):
	if arr[i] < 0:
		negate[i] = negate[i - 1] + 1
	else:
		negate[i] = negate[i - 1]
oe = [[0 for x in range(2)] for y in range(n)]
if negate[-1] % 2 == 0:
	oe[-1][1] += 1
else:
	oe[-1][0] += 1
for i in range(n - 2, -1, -1):
	oe[i][0] = oe[i + 1][0]
	oe[i][1] = oe[i + 1][1]
	if negate[i] % 2 == 0:
		oe[i][1] += 1
	else:
		oe[i][0] += 1
ans = 0
polarity = 0
for i in range(n):
	if polarity == 0:
		if arr[i] > 0:
			ans += oe[i][1]
		else:
			if i + 1 < n:
				ans += oe[i + 1][1]
			polarity = change(polarity)
	elif arr[i] > 0:
		if i + 1 < n:
			ans += oe[i + 1][0]
		ans += 1
	else:
		if i + 1 < n:
			ans += oe[i + 1][0]
		polarity = change(polarity)
print(n * (n + 1) // 2 - ans, ans)


n = input()
a = [int(x) for x in input().split()]
num_positive = [int(a[0] > 0)]
num_negative = [int(a[0] < 0)]
for i in range(1, int(n)):
	if a[i] > 0:
		num_positive.append(num_positive[i - 1] + 1)
		num_negative.append(num_negative[i - 1])
	else:
		num_positive.append(num_negative[i - 1])
		num_negative.append(num_positive[i - 1] + 1)
print(sum(num_negative), sum(num_positive))


n = int(input())
a = list(map(int, input().split()))
pos = [0 for _ in range(n)]
neg = [0 for _ in range(n)]
if a[-1] < 0:
	neg[-1] += 1
else:
	pos[-1] += 1
for i in range(n - 2, -1, -1):
	if a[i] < 0:
		pos[i] = neg[i + 1]
		neg[i] = pos[i + 1] + 1
	else:
		pos[i] = pos[i + 1] + 1
		neg[i] = neg[i + 1]
pos_total = sum(pos)
neg_total = sum(neg)
print(neg_total, pos_total)


import sys

def main():
	n = int(sys.stdin.readline().strip())
	for _ in range(1):
		a = [1 if int(x) > 0 else -1 for x in sys.stdin.readline().strip().split()]
		sum_pos = 0
		sum_neg = 0
		pos = 0
		neg = 0
		for (i, x) in enumerate(a):
			if x > 0:
				npos = pos + 1
				nneg = neg
			else:
				npos = neg
				nneg = pos + 1
			(pos, neg) = (npos, nneg)
			sum_pos += pos
			sum_neg += neg
		print(sum_neg, sum_pos)
main()


n = int(input())
A = list(map(int, input().split()))
pos = 0
neg = 0
posp = 0
negp = 0
for a in A:
	if a > 0:
		posp += 1
		negp = negp
	else:
		negpp = negp
		negp = posp
		negp += 1
		posp = negpp
	pos += posp
	neg += negp
print(neg, pos)


a = int(input())
d = int(a * (a + 1) // 2)
z = list(map(int, input().split()))
t = []
if z[0] > 0:
	t.append([1, 0])
else:
	t.append([0, 1])
for i in range(1, len(z)):
	if z[i] > 0:
		t.append([1 + t[-1][0], t[-1][1]])
	else:
		t.append([t[-1][1], 1 + t[-1][0]])
total = 0
for i in range(len(t)):
	total = total + t[i][0]
print(d - total, total)


n = int(input())
a = [int(x) for x in input().split()]
for i in range(n):
	if a[i] > 0:
		a[i] = 1
	else:
		a[i] = -1
pos = 1
nev = 0
if a[0] == 1:
	pos += 1
else:
	nev += 1
for i in range(1, n):
	a[i] *= a[i - 1]
	if a[i] == 1:
		pos += 1
	else:
		nev += 1
n = n * (n + 1) // 2
res = pos * nev
print(res, n - res)


n = int(input())
array = list(map(int, input().split()))
DP_array = [(0, 0) for i in range(n)]
DP_array[0] = (1, 0) if array[0] > 0 else (0, 1)
for i in range(1, n):
	if array[i] > 0:
		DP_array[i] = (1 + DP_array[i - 1][0], DP_array[i - 1][1])
	else:
		DP_array[i] = (DP_array[i - 1][1], 1 + DP_array[i - 1][0])
sum_pos = sum((pos for (pos, neg) in DP_array))
sum_neg = sum((neg for (pos, neg) in DP_array))
print(str(sum_neg) + ' ' + str(sum_pos))


n = int(input())
a = [int(o) for o in input().split()]
bal = 0
e = 0
o = 0
ans = 0
for i in range(n):
	if bal % 2 == 0:
		e += 1
	else:
		o += 1
	if a[i] < 0:
		bal += 1
	if bal % 2 != 0:
		ans += e
	elif bal % 2 == 0:
		ans += o
print(ans, n * (n + 1) // 2 - ans)


n = int(input())
l = list(map(int, input().split()))
c = []
if l[0] < 0:
	c.append(1)
else:
	c.append(0)
for i in range(1, n):
	if l[i] > 0:
		c.append(c[i - 1])
	else:
		c.append(i + 1 - c[i - 1])
ans1 = sum(c)
ans2 = n * (n + 1) // 2 - ans1
print(ans1, ans2)


n = int(input())
a = list(map(int, input().split()))
ind = [-1]
for i in range(n):
	if a[i] < 0:
		ind.append(i)
ind.append(n)
b = []
for i in range(1, len(ind)):
	b.append(ind[i] - ind[i - 1])
odd = []
even = []
ans = 0
for i in range(len(b)):
	if (i + 1) % 2 == 1 and odd == []:
		odd.append(b[i])
	elif (i + 1) % 2 == 1:
		odd.append(odd[-1] + b[i])
	if (i + 1) % 2 == 0 and even == []:
		even.append(b[i])
	elif (i + 1) % 2 == 0:
		even.append(even[-1] + b[i])
for i in range(len(b) - 1):
	j = i + 2
	if j % 2 == 1:
		if len(odd) >= 1:
			ans += b[i] * (odd[-1] - odd[(j - 1) // 2] + b[j - 1])
	elif len(even) >= 1:
		ans += b[i] * (even[-1] - even[(j - 1) // 2] + b[j - 1])
print(ans, n * (n - 1) // 2 + n - ans)


n = int(input())
arr = [int(s) for s in input().split()]
ans = [0, 0]
last = [0, 0]
now = 0
for i in arr:
	if i < 0:
		now = 1 if now == 0 else 0
	last[now] += 1
ans[0] += last[0]
ans[1] += last[1]
for i in range(1, n):
	if arr[i - 1] < 0:
		(last[0], last[1]) = (last[1], last[0])
	last[0] -= 1
	ans[0] += last[0]
	ans[1] += last[1]
print(ans[1], ans[0])


import math, sys
from collections import defaultdict, deque
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

def I():
	return int(sys.stdin.readline())

def In():
	return map(int, sys.stdin.readline().split())

def Sn():
	return sys.stdin.readline().strip()

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		l = list(In())
		(pos, neg) = ([0], [0])
		for i in range(n):
			if l[i] > 0:
				(a, b) = (pos[-1], neg[-1])
				neg.append(b)
				pos.append(1 + a)
			else:
				(a, b) = (pos[-1], neg[-1])
				neg.append(1 + a)
				pos.append(b)
		print(sum(neg), sum(pos))
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


n = int(input())
l = tuple(map(lambda x: 0 if int(x) > 0 else 1, input().split()))
track = [0, 0]
sums = [0, 0]
for i in l:
	if i:
		(track[0], track[1]) = (track[1], track[0] + 1)
	else:
		track[0] += 1
	sums[0] += track[0]
	sums[1] += track[1]
print(sums[1], sums[0])


n = int(input())
a = list(map(int, input().split()))
left = [0] * n
for (i, el) in enumerate(a):
	if i == 0:
		left[i] = int(el < 0)
	else:
		left[i] = left[i - 1] + int(el < 0)
l_count = [0] * n
for (i, el) in enumerate(left):
	if i == 0:
		l_count[i] = 1
	else:
		l_count[i] = l_count[i - 1] + int(left[i - 1] % 2 == 0)
neg_count = 0
for r in range(n):
	if left[r] % 2 == 1:
		neg_count += l_count[r]
	else:
		neg_count += r + 1 - l_count[r]
pos_count = n * (n + 1) // 2 - neg_count
print(neg_count, pos_count)


n = int(input())
l = [int(s) for s in input().split()]
dp = [[0, 0] for i in range(n)]
if l[0] < 0:
	dp[0][0] = 1
else:
	dp[0][1] = 1
for i in range(1, n):
	if l[i] < 0:
		dp[i][0] = dp[i - 1][1] + 1
		dp[i][1] = dp[i - 1][0]
	else:
		dp[i][0] = dp[i - 1][0]
		dp[i][1] = dp[i - 1][1] + 1
ans1 = sum([i[0] for i in dp])
ans2 = sum([i[1] for i in dp])
print(ans1, ans2)


n = int(input())
lst = [*map(int, input().split())]
(resmin, resplus, plus, minus) = (0, 0, 0, 0)
for (i, x) in enumerate(lst):
	if x < 0:
		(plus, minus) = (minus, plus)
		minus += 1
	else:
		plus += 1
	resmin += minus
	resplus += plus
print(resmin, resplus)


import math
n = int(input())
nums = [-1 if x < 0 else +1 for x in list(map(int, input().strip().split()))]
neg = [0 for x in range(n)]
pos = [0 for x in range(n)]
if nums[0] == 1:
	pos[0] = 1
else:
	neg[0] = 1
for i in range(1, n):
	if nums[i] == 1:
		pos[i] = pos[i - 1]
		neg[i] = neg[i - 1]
	else:
		pos[i] = neg[i - 1]
		neg[i] = pos[i - 1]
	if nums[i] == 1:
		pos[i] += 1
	else:
		neg[i] += 1
print(str(sum(neg)) + ' ' + str(sum(pos)))


n = int(input())
a = list(map(int, input().split()))
prod = 1
cur = 1
neg = 0
for i in range(0, len(a)):
	if a[i] > 0:
		cur *= 1
	else:
		cur *= -1
	if cur < 0:
		neg += 1
print(neg * (n - neg) + neg, n * (n + 1) // 2 - (neg * (n - neg) + neg))


n = int(input())
l = input().split()
li = [int(i) for i in l]
dp = [[0, 0] for i in range(n)]
if li[0] < 0:
	dp[0] = [1, 0]
else:
	dp[0] = [0, 1]
for i in range(1, n):
	if li[i] > 0:
		dp[i][0] = dp[i - 1][0]
		dp[i][1] = i + 1 - dp[i][0]
	else:
		dp[i][1] = dp[i - 1][0]
		dp[i][0] = i + 1 - dp[i][1]
sum1 = 0
sum2 = 0
for i in range(n):
	sum1 += dp[i][0]
	sum2 += dp[i][1]
print(sum1, sum2)


from sys import stdin, stdout
n = int(stdin.readline())
l = [int(x) for x in stdin.readline().split()]
cnt1 = 0
cnt2 = 0
s = 0
c = 0
for x in l:
	if s % 2 == 0:
		cnt1 += 1
	else:
		cnt2 += 1
	if x < 0:
		s += 1
	if s % 2 == 0:
		c += cnt1
	else:
		c += cnt2
n = n * (n + 1) // 2
print(f'{n - c} {c}')


def main():
	import sys
	input = sys.stdin.readline
	n = int(input())
	arr = list(map(int, input().split()))
	cnt = [1, 0]
	lst = [0] * (n + 1)
	lst[0] = 0
	for i in range(n):
		lst[i + 1] = lst[i] ^ (arr[i] < 0)
		cnt[lst[i + 1]] += 1
	ans1 = cnt[0] * cnt[1]
	ans2 = cnt[0] * (cnt[0] - 1) // 2 + cnt[1] * (cnt[1] - 1) // 2
	print(ans1, ans2)
	return 0
main()


import sys
sin = sys.stdin
sin.readline()
arr = sin.readline().split()
arr = [int(i) for i in arr]
lp = ln = ep = en = 0
for i in arr:
	newNeg = 0
	newPos = 0
	if i < 0:
		newNeg = ep + 1
		newPos = en
	if i > 0:
		newNeg = en
		newPos = ep + 1
	lp += ep
	ln += en
	ep = newPos
	en = newNeg
print(ln + en, lp + ep)


n = int(input())
a = list(map(int, input().split()))
posSigns = 1
negSigns = 0
prod = 1
for i in range(n):
	if a[i] < 0:
		prod *= -1
	if prod > 0:
		posSigns += 1
	else:
		negSigns += 1
outPos = posSigns * negSigns
outNeg = n * (n + 1) // 2 - outPos
print(int(outPos), int(outNeg))


n = int(input())
a = [int(x) for x in input().split(' ')]
a = [c // abs(c) for c in a]
p = [1]
for i in range(n):
	p.append(p[-1] * a[i])
del p[0]
m = len([c for c in p if c < 0])
ans = m * (n - m + 1)
print(ans, n * (n + 1) // 2 - ans)


from math import *
from sys import *
from collections import defaultdict
import os, sys
from io import IOBase, BytesIO
M = 10 ** 9 + 7

def pow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a *= a
		b >>= 1
	return res

def inv(a, m):
	return powmod(a, m - 2, m)

def factor(n):
	potentional_p = 3
	itog_list = {}
	if n % 2 == 0:
		itog_list[2] = 0
	while n % 2 == 0:
		n = n // 2
		itog_list[2] += 1
	while n - 1:
		if potentional_p > n ** 0.5:
			if n in itog_list:
				itog_list[n] += 1
			else:
				itog_list[n] = 1
			return itog_list
		while n % potentional_p == 0:
			n = n // potentional_p
			if potentional_p in itog_list:
				itog_list[potentional_p] += 1
			else:
				itog_list[potentional_p] = 1
		potentional_p += 2
	return itog_list

def sign(x):
	if x > 0:
		return 1
	return -1

def sign1(x, y):
	if x * y > 0:
		return 1
	return -1

def prod(arr):
	val = 1
	for x in arr:
		val *= x
	return val

def main():
	n = int(input())
	a = list(map(int, input().split()))
	arr = []
	val = 0
	for x in a:
		if x < 0:
			arr.append(val + 1)
			val = 0
		else:
			val += 1
	arr.append(val + 1)
	sum1 = 0
	sum2 = 0
	for i in range(len(arr)):
		if i % 2 == 1:
			sum1 += arr[i]
		else:
			sum2 += arr[i]
	res = 0
	for i in range(len(arr)):
		if i % 2 == 0:
			res += arr[i] * sum1
			sum2 -= arr[i]
		else:
			res += arr[i] * sum2
			sum1 -= arr[i]
	print(res, n * (n + 1) // 2 - res)
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = input()
A = list(map(int, list(a.split())))
pos = [0] * n
neg = [0] * n
if A[0] > 0:
	pos[0] = 1
else:
	neg[0] = 1
for i in range(1, n):
	if A[i] > 0:
		pos[i] = pos[i - 1] + 1
		neg[i] = neg[i - 1]
	else:
		pos[i] = neg[i - 1]
		neg[i] = pos[i - 1] + 1
print(sum(neg), end=' ')
print(sum(pos))


N = int(input())
d = 1
pl = 0
mn = 0
apl = 0
amn = 0
for k in map(int, input().split()):
	if k < 0:
		d = d * -1
	if d < 0:
		apl += mn
		amn += pl
	else:
		apl += pl
		amn += mn
	if d < 0:
		mn += 1
		amn += 1
	else:
		pl += 1
		apl += 1
print(amn, apl)


a = int(input())
l = list(map(int, input().strip().split()))
neg = [0]
pos = [0]
for i in l:
	t = neg[-1]
	v = pos[-1]
	if i < 0:
		pos.append(t)
		neg.append(v + 1)
	else:
		pos.append(v + 1)
		neg.append(t)
n = 0
p = 0
for i in range(len(pos)):
	n += neg[i]
	p += pos[i]
print(n, p)


n = int(input())
l = list(map(int, input().split()))
Ln = [0 for i in range(n)]
Lp = [0 for i in range(n)]
if l[0] >= 0:
	Lp[0] = 1
else:
	Ln[0] = 1
for i in range(1, n):
	if l[i] >= 0:
		Lp[i] = Lp[i - 1] + 1
		Ln[i] = Ln[i - 1]
	else:
		Lp[i] = Ln[i - 1]
		Ln[i] = Lp[i - 1] + 1
print(sum(Ln), sum(Lp))


def solve():
	n = int(input())
	arr = list(map(int, input().split(' ')))
	matrix = []
	negative = 0
	positive = 0
	initial = [0, 0]
	if arr[len(arr) - 1] > 0:
		initial[1] = 1
		positive += 1
	else:
		initial[0] = 1
		negative += 1
	matrix.append(initial)
	for i in range(len(arr) - 2, -1, -1):
		value = arr[i]
		tmp = [0, 0]
		if value > 0:
			tmp[1] = matrix[-1][1] + 1
			tmp[0] = matrix[-1][0]
		else:
			tmp[1] = matrix[-1][0]
			tmp[0] = matrix[-1][1] + 1
		matrix.append(tmp)
		positive += matrix[-1][1]
		negative += matrix[-1][0]
	print(negative, positive)
solve()


def ans():
	sum = 0
	anns = [1, 0]
	nums = 0
	for i in range(n):
		if v[i] < 0:
			nums += 1
			sum += anns[1 - nums % 2]
			anns[nums % 2] += 1
		elif v[i] > 0:
			sum += anns[1 - nums % 2]
			anns[nums % 2] += 1
		elif v[i] == 0:
			anns[0] = 1
			anns[1] = 0
			nums = 0
	return sum

def sna():
	sum = 0
	anns = [1, 0]
	nums = 0
	for i in range(n):
		if v[i] < 0:
			nums += 1
			sum += anns[nums % 2]
			anns[nums % 2] += 1
		elif v[i] > 0:
			sum += anns[nums % 2]
			anns[nums % 2] += 1
		elif v[i] == 0:
			anns[0] = 1
			anns[1] = 0
			nums = 0
	return sum
n = int(input())
v = [int(i) for i in input().split()]
print(ans(), sna())


n = int(input())
l = [int(j) for j in input().split()]
t = 0
ch = 0
nch = 0
(ans1, ans2) = (0, 0)
for i in range(n):
	if t % 2 == 0:
		nch += 1
	else:
		ch += 1
	if l[i] < 0:
		t += 1
	if t % 2 == 0:
		ans1 += nch
	else:
		ans1 += ch
print(n * (n + 1) // 2 - ans1, ans1)


R = lambda : map(int, input().split())
n = int(input())
L = list(R())
t = []
c = 0
ne = 0
for i in range(n):
	if L[i] < 0:
		t.append(c)
		c = 0
		ne += 1
	else:
		c += 1
t.append(c)
l = len(t)
res = 0
(es, os) = (0, 0)
for i in range(1, l, 2):
	os += t[i]
for i in range(2, l, 2):
	es += t[i]
b = (ne + 1) // 2
(o, e) = (1, 2)
(c1, c2) = ((ne + 1) // 2, ne // 2)
for i in range(ne):
	if i % 2 == 0:
		res += (1 + t[i]) * (c1 + os)
		os -= t[o]
		o += 2
		c1 -= 1
	else:
		res += (1 + t[i]) * (c2 + es)
		es -= t[e]
		e += 2
		c2 -= 1
p = n * (n + 1) // 2
print(res, p - res)


n = int(input())
a = list(map(int, input().split()))
pos = 1
neg = 0
for i in range(n):
	if a[i] > 0:
		a[i] = 1
	else:
		a[i] = -1
	if i > 0:
		a[i] *= a[i - 1]
	if a[i] == 1:
		pos += 1
	else:
		neg += 1
negative = pos * neg
tot = n * (n + 1) // 2
print(negative, tot - negative)


n = int(input())
a = b = ansa = ansb = 0
L = list(map(int, input().split()))
for i in range(n):
	if L[i] > 0:
		a += 1
	else:
		c = a
		a = b
		b = c + 1
	ansa += a
	ansb += b
print(ansb, ansa)


n = int(input())
a = [i for (i, x) in enumerate(input().split()) if int(x) < 0]
a = [-1] + a + [n]
l = [a[i] - a[i - 1] for i in range(1, len(a) - 1)]
r = [a[i + 1] - a[i] for i in range(1, len(a) - 1)]
ls = [0 for i in range(len(l))]
if len(ls) > 0:
	ls[0] = l[0]
if len(ls) > 1:
	ls[1] = l[1]
for i in range(2, len(ls)):
	ls[i] = ls[i - 2] + l[i]
s_m = 0
for (li, ri) in zip(ls, r):
	s_m += li * ri
s_p = n * (n + 1) // 2 - s_m
print(s_m, s_p)


n = int(input())
ll = list(map(int, input().split()))
l = [1 if ll[i] < 0 else 0 for i in range(n)]
l = [0] + l
pref = [0] * (n + 1)
pref[0] = l[0]
for i in range(1, n + 1):
	pref[i] = pref[i - 1] + l[i]
par = 0
for i in pref:
	if i % 2 == 0:
		par += 1
pospr = (par * (par - 1) + (n + 1 - par) * (n - par)) // 2
negpr = n * (n + 1) // 2 - pospr
print(negpr, pospr)


n = int(input())
dat = [int(q[0] == '-') for q in input().split()]
d = [0] * n
s = 0
for i in range(n):
	if dat[i]:
		s = 1 - s
	d[i] = s
r1 = sum(d)
even = True
cnt = 0
if True:
	cnt = r1
else:
	cnt = n - r1
if d[0]:
	r1 -= 1
for i in range(1, n):
	if not d[i - 1]:
		inc = r1
	else:
		inc = n - i - r1
	cnt += inc
	if d[i]:
		r1 -= 1
print(cnt, n * (n + 1) // 2 - cnt)


n = int(input())
arr = list(map(int, input().split()))
for i in range(n):
	arr[i] = arr[i] // abs(arr[i])
pref = [1]
for i in range(n):
	pref.append(pref[-1] * arr[i])
plus = minus = 0
res_pl = res_mn = 0
for i in range(n + 1):
	if pref[i] == 1:
		res_pl += plus
		res_mn += minus
		plus += 1
	else:
		res_pl += minus
		res_mn += plus
		minus += 1
print(res_mn, res_pl)


from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def solve():
	n = ii()
	a = li()
	dp = [[0, 0] for i in range(n + 1)]
	(pos, neg) = (0, 0)
	for i in range(n):
		if a[i] > 0:
			dp[i + 1][0] = dp[i][0] + 1
			dp[i + 1][1] = dp[i][1]
		else:
			dp[i + 1][0] = dp[i][1]
			dp[i + 1][1] = dp[i][0] + 1
		pos += dp[i + 1][0]
		neg += dp[i + 1][1]
	print(neg, pos)
solve()


import collections
import itertools

class CumulativeSum(object):

	def __init__(self, sequence):
		self.cumulative_sum = [0]
		self.cumulative_sum.extend(itertools.accumulate(sequence))

	def partial_sum(self, first, last):
		return self.cumulative_sum[last + 1] - self.cumulative_sum[first]

def compute(n, xs):
	cs = CumulativeSum((int(x < 0) for x in xs))
	mods = [y % 2 for y in cs.cumulative_sum]
	ctr = collections.Counter(mods)
	num_all = n + n * (n - 1) // 2
	num_poss = ctr[1] * (ctr[1] - 1) // 2 + ctr[0] * (ctr[0] - 1) // 2
	num_negs = num_all - num_poss
	return (num_negs, num_poss)

def main():
	n = int(input())
	xs = [int(x) for x in input().split()]
	res = compute(n, xs)
	print(*res)
main()


overall = int(input())
nums = [int(item) for item in input().split()]
pos_counts = [0 for i in range(len(nums))]
neg_counts = [0 for i in range(len(nums))]
largest_signs = [1 for i in range(len(nums))]
pos_count = 0
neg_count = 0
largest_pos_count = 0
largest_neg_count = 0
for (new_i, num) in enumerate(nums):
	if num < 0:
		swap = largest_pos_count
		largest_pos_count = largest_neg_count
		largest_neg_count = swap
	pos_count += largest_pos_count
	neg_count += largest_neg_count
	if num > 0:
		largest_pos_count += 1
		pos_count += 1
	else:
		largest_neg_count += 1
		neg_count += 1
print(neg_count, pos_count)