You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.

Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.

You should write a program which finds sum of the best subsequence.


-----Input-----

The first line contains integer number n (1 ≤ n ≤ 10^5).

The second line contains n integer numbers a_1, a_2, ..., a_{n} ( - 10^4 ≤ a_{i} ≤ 10^4). The sequence contains at least one subsequence with odd sum.


-----Output-----

Print sum of resulting subseqeuence.


-----Examples-----
Input
4
-2 2 -3 1

Output
3

Input
3
2 -5 -3

Output
-1



-----Note-----

In the first example sum of the second and the fourth elements is 3.

Difficulty: MEDIUM

Solutions:
n = int(input())
arr = list(map(int, input().split()))
s = 0
odd = []
for element in arr:
	if element > 0:
		s += element
if s % 2 == 1:
	print(s)
else:
	for element in arr:
		if element % 2 == 1:
			odd.append(abs(element))
	print(s - min(odd))


n = int(input())
l = list(map(int, input().split()))
su = 0
l1 = []
for x in l:
	if x % 2 == 0 and x > 0:
		su += x
	elif abs(x) % 2 != 0:
		l1.append(x)
l1 = sorted(l1)
l1 = l1[::-1]
su += l1[0]
for i in range(2, len(l1), 2):
	q = l1[i] + l1[i - 1]
	if q > 0:
		su += q
print(su)


n = int(input())
tab = map(int, input().split())
tab = sorted(tab, reverse=True)
maxi = 0
tmpOdd = 0
maxOdd = 0
oddFirst = True
for i in tab:
	if i % 2 == 0 and i > 0:
		maxi += i
	elif i % 2 == 1:
		tmpOdd += i
		if tmpOdd % 2 == 1:
			if maxOdd < tmpOdd or oddFirst:
				oddFirst = False
				maxOdd = tmpOdd
maxi += maxOdd
print(maxi)


n = int(input())
vals = input().split()
a_list = [int(val) for val in vals]
max_even = None
max_odd = None
for a in a_list:
	me = max_even
	mo = max_odd
	if a % 2 == 0:
		if mo is not None:
			max_odd = max(mo, mo + a)
		if me is not None:
			max_even = max(me, a, me + a)
		else:
			max_even = a
	elif me is None and mo is None:
		max_odd = a
	elif me is None:
		max_odd = max(mo, a)
		max_even = mo + a
	elif mo is None:
		max_odd = max(me + a, a)
	else:
		max_odd = max(mo, me + a, a)
		max_even = max(me, mo + a)
print(max_odd)


x = int(input())
s = list(map(int, input().split(' ')))
kek = 10000
answer = 0
for i in range(0, len(s)):
	if s[i] > 0:
		answer += s[i]
	if abs(s[i]) < kek and s[i] % 2 == 1:
		kek = abs(s[i])
if answer % 2 == 0:
	print(answer - kek)
else:
	print(answer)


n = int(input())
A = list(map(int, input().split()))
dp = [[-9999999999, -9999999999]]
for elem in A:
	dp += [[0, 0]]
	if elem % 2 == 0:
		dp[-1][0] = max(dp[-2][0] + elem, dp[-2][0], elem)
		dp[-1][1] = max(dp[-2][1] + elem, dp[-2][1])
	else:
		dp[-1][0] = max(dp[-2][1] + elem, dp[-2][0])
		dp[-1][1] = max(dp[-2][0] + elem, dp[-2][1], elem)
print(dp[-1][1])


input()
nums = sorted((int(x) for x in input().split()))
s = 0
(odds, s) = ([], 0)
for n in nums:
	if n % 2 != 0:
		odds.append(n)
	elif n > 0:
		s += n
(cnt, last) = (0, None)
while True:
	if not odds:
		break
	if odds[-1] < 0:
		break
	o = odds.pop(-1)
	s += o
	last = o
	cnt += 1
if last is None:
	print(s + odds[-1])
elif cnt % 2 != 0:
	print(s)
elif not odds:
	print(s - last)
else:
	print(s + (-last if -odds[-1] > last else odds[-1]))


n = int(input())
a = list(map(int, input().split()))
neg = list()
pos = list()
for i in range(n):
	if a[i] < 0:
		neg.append(a[i])
	elif a[i] > 0:
		pos.append(a[i])
sn = sum(pos)
mnp = 100000
mxn = -100000
for i in range(len(neg)):
	if neg[i] % 2 == 1 and neg[i] > mxn:
		mxn = neg[i]
for j in range(len(pos)):
	if pos[j] % 2 == 1 and pos[j] < mnp:
		mnp = pos[j]
mxn *= -1
if sn % 2 == 0:
	print(sn - min(mnp, mxn))
else:
	print(sn)


n = int(input())
l = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
l4 = []
for i in l:
	if i > 0:
		if i % 2 == 0:
			l1.append(i)
		else:
			l2.append(i)
	elif i < 0:
		if i % 2 == 0:
			l3.append(i)
		else:
			l4.append(i)
l1.sort()
l2.sort()
l3.sort()
l4.sort()
ans = sum(l1) + sum(l2)
if ans % 2 != 0:
	print(ans)
elif len(l4) != 0 and len(l2) != 0:
	if l2[0] > abs(l4[-1]):
		print(ans + l4[-1])
	else:
		print(ans - l2[0])
elif len(l4) == 0 and len(l2) != 0:
	print(ans - l2[0])
elif len(l4) != 0 and len(l2) == 0:
	print(ans + l4[-1])


n = int(input())
a = list(map(int, input().split()))
a.sort(key=lambda x: -x)
s_p = sum(filter(lambda x: x > 0, a))
if s_p % 2 == 1:
	print(s_p)
else:
	m_p = list(filter(lambda x: x > 0 and x % 2 == 1, a))
	m_n = list(filter(lambda x: x < 0 and x % 2 == 1, a))
	if len(m_p) > 0 and len(m_n) > 0:
		s_p += max(-min(m_p), max(m_n))
	elif len(m_p) == 0 and len(m_n) > 0:
		s_p += max(m_n)
	else:
		s_p += -min(m_p)
	print(s_p)


n = int(input())
l = list(map(int, input().split()))
maxi = max(l)
if maxi < 0:
	if abs(maxi) % 2 == 1:
		print(maxi)
	else:
		mini = -10 ** 9
		for i in range(n):
			if l[i] > mini and abs(l[i]) % 2 == 1:
				mini = l[i]
		print(max(maxi + mini, mini))
else:
	odd = 0
	even = 0
	neg = []
	min_odd = 10 ** 9
	for i in range(n):
		if l[i] > 0 and l[i] % 2 == 1:
			odd += l[i]
			if l[i] < min_odd:
				min_odd = l[i]
		elif l[i] > 0 and l[i] % 2 == 0:
			even += l[i]
		else:
			neg.append(l[i])
	if (odd + even) % 2 == 1:
		print(odd + even)
	else:
		mini = -10 ** 9
		for i in range(len(neg)):
			if abs(neg[i]) % 2 == 1 and neg[i] > mini:
				mini = neg[i]
		print(max(odd + even + mini, odd + even - min_odd))


def main():
	input()
	(aa, l) = (list(map(int, input().split())), [])
	for (i, a) in enumerate(aa):
		if a & 1:
			l.append(i)
		elif a < 0:
			aa[i] = 0
	l.sort(key=aa.__getitem__)
	i = 1 - len(l) & 1
	if i:
		aa[l[0]] = 0
	for (j, k) in zip(l[i::2], l[i + 1::2]):
		if aa[j] + aa[k] >= 0:
			break
		aa[j] = aa[k] = 0
	print(sum(aa))
main()


n = int(input())
a = list(map(int, input().split()))
odds = 0
evens = 0
even_sum = 0
odd_sum = 0
ev_min = 100000
odd_min = 100000
neg_ev_max = -1000000
neg_odd_max = -1000000
for x in a:
	if x >= 0:
		if x % 2 == 0:
			even_sum += x
			evens += 1
			ev_min = min(ev_min, x)
		else:
			odd_sum += x
			odd_min = min(x, odd_min)
			odds += 1
	elif x % 2 == 0:
		neg_ev_max = max(x, neg_ev_max)
	else:
		neg_odd_max = max(x, neg_odd_max)
ans = -100000000000
if odds > 0:
	ans = even_sum + odd_sum
	if odds % 2 == 0:
		ans = ans - odd_min
		if neg_odd_max != -1000000:
			ans = max(ans, ans + odd_min + neg_odd_max)
if neg_odd_max != -1000000:
	ans = max(ans, even_sum + neg_odd_max, neg_odd_max)
if neg_ev_max != -1000000:
	ans = max(ans, neg_odd_max + neg_ev_max)
print(ans)


n = int(input())
l = list(map(int, input().split()))
su = 0
minodd = 2147483647
for i in range(n):
	if l[i] > 0:
		su += l[i]
	if l[i] % 2 != 0:
		minodd = min(abs(l[i]), minodd)
if su % 2 != 0:
	print(su)
else:
	print(su - minodd)


n = int(input())
x = sorted(map(int, input().split()))
s = 0
odd = []
ev = []
for i in range(n):
	if x[i] % 2 == 0:
		if x[i] > 0:
			s += x[i]
	else:
		odd += [x[i]]
s += odd[-1]
j = len(odd) - 2
while j >= 1:
	if odd[j] + odd[j - 1] > 0:
		s += odd[j] + odd[j - 1]
		j -= 2
	else:
		break
print(s)


n = int(input())
arr = list(map(int, input().strip().split(' ')))
s = 0
pos = []
neg = []
for i in arr:
	if i % 2 == 0:
		s += max(0, i)
	elif i >= 0:
		pos.append(i)
	else:
		neg.append(i)
pos.sort(reverse=True)
neg.sort(reverse=True)
if len(pos) % 2 == 1:
	s += sum(pos[:])
elif len(pos) > 0:
	if len(neg) > 0:
		if pos[len(pos) - 1] > abs(neg[0]):
			s = s + sum(pos[:]) + neg[0]
		else:
			s += sum(pos[:len(pos) - 1])
	elif len(pos) > 1:
		s += sum(pos[:len(pos) - 1])
	else:
		s += pos[0]
else:
	s += neg[0]
print(s)


n = input()
seq = list(map(int, input().split()))
positive = list(filter(lambda x: x > 0, seq))
negative = list(filter(lambda x: x < 0, seq))
s = sum(positive)
if s % 2 == 0:
	p = list(map(lambda x: -x, positive))
	remove = sorted(p + negative)
	for i in range(len(remove) - 1, -1, -1):
		if (s + remove[i]) % 2 == 1:
			s += remove[i]
			break
print(s)


n = int(input())
li = list(map(int, input().split()))
pos_sum = 0
mop = False
mon = False
min_od = int(pow(10, 6))
max_od = int(pow(10, 6))
max_od *= -1
for i in range(n):
	if li[i] > 0:
		pos_sum += li[i]
		if li[i] % 2 != 0:
			mop = True
			min_od = min(min_od, li[i])
	elif abs(li[i]) % 2 != 0:
		mon = True
		max_od = max(max_od, li[i])
if pos_sum % 2 != 0:
	print(pos_sum)
elif mon == True and mop == True:
	print(max(pos_sum + max_od, pos_sum - min_od))
elif mon == True:
	print(pos_sum + max_od)
else:
	print(pos_sum - min_od)


n = int(input())
a = [int(x) for x in input().split()]
dp = [[0 for x in range(2)] for y in range(n)]
dp[0][not a[0] % 2] = 0
dp[0][a[0] % 2] = a[0]
for i in range(1, n):
	if a[i] % 2 == 0:
		dp[i][0] = max(a[i] + dp[i - 1][0], dp[i - 1][0], a[i])
		if dp[i - 1][1] != 0:
			dp[i][1] = max(a[i] + dp[i - 1][1], dp[i - 1][1])
		else:
			dp[i][1] = dp[i - 1][1]
	elif dp[i - 1][1] != 0:
		dp[i][1] = max(a[i] + dp[i - 1][0], dp[i - 1][1], a[i])
		dp[i][0] = max(a[i] + dp[i - 1][1], dp[i - 1][0])
	else:
		dp[i][1] = max(a[i] + dp[i - 1][0], a[i])
		dp[i][0] = dp[i - 1][0]
print(dp[-1][1])


inf = int(1000000.0)
n = int(input())
arr = list(map(int, input().split()))
sm = 0
(mx, mn) = (-inf, inf)
for i in arr:
	if i > 0:
		sm += i
	if i & 1:
		if i > 0:
			mn = min(mn, i)
		elif i < 0:
			mx = max(mx, i)
if sm & 1:
	print(sm)
else:
	print(sm - min(-mx, mn))


n = int(input())
A = [int(num) for num in input().split()]
odd = sorted(list(filter(lambda t: t % 2 != 0, A)), reverse=True)
even = sorted(list(filter(lambda t: t % 2 == 0, A)), reverse=True)
max_ev = 0
i = 0
while i < len(even) and even[i] > 0:
	max_ev += even[i]
	i += 1
d = []
for j in odd:
	if d == []:
		d.append(j)
	else:
		d.append(j + d[-1])
i = 0
m_o = None
while i < len(d):
	if m_o is None:
		m_o = d[i]
	elif d[i] > m_o:
		m_o = d[i]
	i += 2
if max_ev > 0:
	m_o += max_ev
print(m_o)


n = int(input())
arr = list(map(int, input().split()))
(o, e) = (-10 ** 8, -10 ** 8)
for i in range(n):
	if i == 0 and arr[i] % 2:
		o = arr[i]
	elif i == 0 and arr[i] % 2 == 0:
		e = arr[i]
	elif arr[i] % 2 == 0:
		if o != -10 ** 8:
			o = max(o, arr[i] + o)
		e = max(e, e + arr[i], arr[i])
	else:
		temp = e
		if o != -10 ** 8:
			e = max(e, o + arr[i])
		o = max(o, temp + arr[i], arr[i])
print(o)


def max(a, b):
	if a > b:
		return a
	else:
		return b

def min(a, b):
	if a < b:
		return a
	else:
		return b

def __starting_point():
	n = int(input())
	A = input().split(' ')
	(ans, count, Min, Max) = (0, 0, 1000000000, -100000000000)
	for i in range(n):
		now = int(A[i])
		if now % 2 == 0:
			ans += max(now, 0)
		elif now < 0:
			Max = max(Max, now)
		else:
			Min = min(Min, now)
			ans += now
	if ans % 2 == 0:
		ans = max(ans - Min, ans + Max)
	print(ans)
__starting_point()


n = int(input())
a = list(map(int, input().split()))
d = []
a.sort()
e = []
for j in range(n):
	if a[j] >= 0:
		d.append(a[j])
	else:
		e.append(a[j])
if len(d) == 0:
	for j in range(n - 1, -1, -1):
		if a[j] % 2 == 1:
			val = a[j]
			break
else:
	s = sum(d)
	if s % 2 == 1:
		val = s
	else:
		flag = 0
		s1 = s
		s2 = s
		for j in range(len(d)):
			if d[j] % 2 == 1:
				flag = 1
				s1 -= d[j]
				break
		flag1 = 0
		for j in range(len(e) - 1, -1, -1):
			if e[j] % 2 == 1:
				flag1 = 1
				s2 += e[j]
				break
		if flag == 0:
			val = s2
		elif flag1 == 0:
			val = s1
		else:
			val = max(s1, s2)
print(val)


n = int(input())
o1 = []
o2 = []
e1 = []
e2 = []
l = list(map(int, input().split()))
for i in range(n):
	if l[i] % 2 == 0:
		if l[i] < 0:
			e1.append(l[i])
		elif l[i] > 0:
			e2.append(l[i])
	elif l[i] > 0:
		o2.append(l[i])
	elif l[i] < 0:
		o1.append(l[i])
if len(o2) == 0:
	print(max(o1) + sum(e2))
elif len(o2) % 2 == 0:
	a2 = sum(o2) + sum(e2) - min(o2)
	if len(o1) > 0:
		a1 = sum(o2) + sum(e2) + max(o1)
		print(max(a1, a2))
	else:
		print(a2)
else:
	print(sum(o2) + sum(e2))


n = int(input())
a = input().split()
s = 0
mc = 10001
mn = -10001
for i in a:
	i = int(i)
	if i > 0:
		s += i
		if i % 2 != 0 and i < mc:
			mc = i
	elif i > mn and i % 2 != 0:
		mn = i
if s % 2 != 0:
	print(s)
elif s == 0:
	print(mn)
else:
	print(s - min(mc, mn * -1))


n = int(input())
l = list(map(int, input().split()))
odd = []
even = []
for i in range(n):
	if l[i] % 2 == 0:
		if l[i] > 0:
			even.append(l[i])
	else:
		odd.append(l[i])
odd.sort(reverse=True)
even.sort(reverse=True)
ans = 0
for i in range(len(odd)):
	if odd[i] < 0:
		if ans == 0:
			ans += odd[i]
			break
		else:
			if i % 2 == 0:
				if abs(odd[i - 1]) < abs(odd[i]):
					ans -= odd[i - 1]
				else:
					ans += odd[i]
			break
	else:
		ans += odd[i]
if odd[-1] >= 0 and len(odd) % 2 == 0:
	ans -= odd[-1]
print(ans + sum(even))


n = int(input())
l = list(map(int, input().split()))
p = 9999
ne = -9999
s = 0
for i in l:
	if i > 0:
		s += i
		if i % 2 == 1 and i < p:
			p = i
	elif i % 2 == 1 and i > ne:
		ne = i
if s % 2 == 0:
	print(s - min(p, -ne))
else:
	print(s)


n = int(input())
arr = list(map(int, input().split()))
s = sum([a for a in arr if a > 0])
if s % 2 == 1:
	print(s)
else:
	mn_odd = 10001
	for ele in arr:
		if ele % 2 == 1 and ele > 0:
			mn_odd = min(mn_odd, ele)
	mx_odd = -10001
	for ele in arr:
		if ele % 2 == 1 and ele < 0:
			mx_odd = max(mx_odd, ele)
	print(max(s - mn_odd, s + mx_odd))


n = int(input())
ai = list(map(int, input().split()))
ans = 0
for i in range(n):
	if ai[i] > 0:
		ans += ai[i]
if ans % 2 == 1:
	print(ans)
else:
	mini = 100000000
	maxi = -1000000
	for i in range(n):
		if ai[i] > 0 and ai[i] % 2 == 1:
			if mini > ai[i]:
				mini = ai[i]
		elif ai[i] < 0 and ai[i] % 2 == 1:
			if maxi < ai[i]:
				maxi = ai[i]
	maxi = abs(maxi)
	print(ans - min(mini, maxi))


input()
items = list(map(int, input().split()))
out = sum(filter(lambda n: n > 0, items))
if out % 2 == 0:
	out = out - min(map(abs, filter(lambda n: n % 2 == 1, items)))
print(out)


from sys import stdin
from collections import defaultdict
input = stdin.readline
T = 1
for t in range(1, T + 1):
	n = int(input())
	_input = list(map(int, input().split()))
	_sum = 0
	for i in _input:
		_sum += 0 if i < 0 else i
	if _sum & 1:
		print(_sum)
		exit()
	_temp_sum = -10000000000
	for i in range(0, len(_input)):
		if _input[i] > 0:
			if _sum - _input[i] > _temp_sum and _sum - _input[i] & 1:
				_temp_sum = _sum - _input[i]
		elif _sum + _input[i] > _temp_sum and _sum + _input[i] & 1:
			_temp_sum = _sum + _input[i]
	print(_temp_sum)


n = int(input())
posdd = []
odd = []
even = 0
t = list(map(int, input().split()))
for j in range(n):
	if abs(t[j]) % 2 == 0:
		if t[j] > 0:
			even += t[j]
	elif t[j] > 0:
		posdd.append(t[j])
		even += t[j]
	else:
		odd.append(t[j])
if even % 2:
	print(even)
else:
	u = 99999999999
	if len(odd) > 0:
		u = min(u, -max(odd))
	if len(posdd) > 0:
		u = min(u, min(posdd))
	print(even - u)


n = int(input())
(maxOdd, maxEven) = (-1000000001, 0)
for x in map(int, input().split()):
	if x % 2 == 1:
		(maxOdd, maxEven) = (max(maxOdd, maxEven + x), max(maxEven, maxOdd + x))
	elif x > 0:
		maxOdd += x
		maxEven += x
print(maxOdd)


n = int(input())
a = list(map(int, input().split()))
(s, r, t, o) = (0, [], [], [])
for i in a:
	if i > 0:
		s += i
if s % 2 == 0:
	for i in a:
		if i > 0 and i % 2 == 1:
			r += [i]
		elif i < 0 and i % 2 == 1:
			t += [i]
	q = s - (min(r) if r else 0)
	w = s + (max(t) if t else 0)
	if q % 2 == 1:
		o += [q]
	if w % 2 == 1:
		o += [w]
	print(max(o))
else:
	print(s)


import sys
n = int(sys.stdin.readline())
l = list(map(int, sys.stdin.readline().split()))
ans = 0
for i in range(n):
	if l[i] > 0:
		ans += l[i]
max_odd_neg = -10 ** 5
min_odd_pos = 10 ** 5
for i in range(n):
	if l[i] % 2 == 1:
		if l[i] > 0:
			min_odd_pos = min(min_odd_pos, l[i])
		elif l[i] < 0:
			max_odd_neg = max(max_odd_neg, l[i])
if ans % 2 == 0:
	ans -= min(min_odd_pos, -max_odd_neg)
print(ans)


import traceback
import math
from collections import defaultdict
from functools import lru_cache
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')

def geti():
	return int(input())

def gets():
	return input()

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

def getsl():
	return input().split()

def get2d(nrows, ncols, n=0):
	return [[n] * ncols for r in range(nrows)]
inf = float('inf')
mod = 10 ** 9 + 7

def main():
	N = geti()
	a = getil()
	s = sum((n for n in a if n > 0))
	oddmin = min([n for n in a if n & 1 and n > 0] + [inf])
	oddmax = max([n for n in a if n & 1 and n < 0] + [-inf])
	if s & 1:
		return s
	else:
		return s - min(abs(oddmin), abs(oddmax))
try:
	ans = main()
	print(ans)
except Exception as e:
	traceback.print_exc()


from sys import stdout
from sys import stdin

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

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

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

def putf(a, sep=' ', end='\n'):
	stdout.write(sep.join(map(str, a)) + end)

def main():
	n = int(get())
	a = getf()
	odPos = []
	odNeg = []
	(xp, xn) = (0, 0)
	sm = 0
	for i in range(n):
		if a[i] % 2 == 0:
			if a[i] > 0:
				sm += a[i]
		elif a[i] > 0:
			odPos += [a[i]]
			xp += 1
		else:
			odNeg += [a[i]]
			xn += 1
	if xp % 2 == 1:
		sm += sum(odPos)
	elif xp == 0:
		sm += max(odNeg)
	elif xn == 0:
		sm += sum(odPos) - min(odPos)
	else:
		(a, b) = (min(odPos), max(odNeg))
		if -b > a:
			sm += sum(odPos) - a
		else:
			sm += sum(odPos) + b
	put(sm)
main()


n = int(input())
arr = list(map(int, input().split()))
smallest_odd = 10 ** 9
greatest_neg_odd = -10 ** 9
ans = 0
for i in arr:
	if i > 0:
		ans += i
	if i > 0 and i % 2 != 0:
		smallest_odd = min(smallest_odd, i)
	if i < 0 and i % 2 != 0:
		greatest_neg_odd = max(greatest_neg_odd, i)
if ans % 2 != 0:
	print(ans)
elif ans % 2 == 0:
	print(max(ans - smallest_odd, ans + greatest_neg_odd))


n = int(input())
a = list(map(int, input().split()))
cn = sum([val for val in a if val % 2 == 0 and val > 0])
odd = [val for val in a if val & 1]
odd.sort()
if odd[-1] < 0:
	cn += odd[-1]
else:
	pos = [val for val in odd if val > 0]
	neg = [val for val in odd if val < 0]
	sz = len(pos)
	cn += sum(pos[sz + 1 & 1:])
	if neg != [] and pos[0] + neg[-1] > 0 and sz + 1 & 1:
		cn += pos[0] + neg[-1]
print(cn)


from math import inf
n = int(input())
numbers = [int(x) for x in input().split()]
soma = 0
m = inf
for i in numbers:
	if i > 0:
		soma += i
	if i % 2 == 1:
		m = min(m, abs(i))
if soma % 2 == 0:
	soma -= m
print(soma)


n = int(input())
l = list(map(int, input().split()))
(l1, l2, l1e, l1o, l2e, l2o) = ([], [], [], [], [], [])
for i in range(len(l)):
	if l[i] >= 0:
		l1.append(l[i])
	else:
		l2.append(l[i])
for i in range(len(l)):
	if l[i] >= 0 and l[i] % 2 == 0 and (l[i] != 0):
		l1e.append(l[i])
	elif l[i] >= 0 and l[i] % 2 != 0 and (l[i] != 0):
		l1o.append(l[i])
	elif l[i] < 0 and l[i] % 2 == 0 and (l[i] != 0):
		l2e.append(l[i])
	elif l[i] < 0 and l[i] % 2 != 0 and (l[i] != 0):
		l2o.append(l[i])
l1.sort()
l2.sort()
l1o.sort()
l1e.sort()
l2o.sort()
l2e.sort()
if sum(l1) % 2 != 0:
	print(sum(l1))
elif len(l1o) != 0 and len(l2o) != 0:
	print(sum(l1) - min(min(l1o), abs(max(l2o))))
elif len(l1o) != 0 and len(l2o) == 0:
	print(sum(l1) - min(l1o))
else:
	print(sum(l1) - abs(max(l2o)))


n = int(input())
l = list(map(int, input().split()))
sum_l = int(0)
(m1, m2) = (-10 ** 5, 10 ** 5)
for ele in l:
	if ele > 0:
		sum_l += ele
	if ele % 2 != 0:
		if ele < 0:
			m1 = max(m1, ele)
		else:
			m2 = min(m2, ele)
if sum_l % 2 != 0:
	print(sum_l)
else:
	if m1 != -10 ** 5 and m2 != 10 ** 5:
		if abs(m1) < abs(m2):
			sum_l += m1
		else:
			sum_l -= m2
	elif m1 != -10 ** 5:
		sum_l += m1
	else:
		sum_l -= m2
	print(sum_l)


n = int(input())
l = [int(i) for i in input().split()]
l.sort()
a = 0
for i in l:
	if i > 0:
		a += i
x = float('inf')
y = -1 * x
if a % 2 == 0:
	for i in l:
		if i % 2 != 0 and i < 0:
			y = max(y, i)
		elif i % 2 != 0 and i > 0:
			x = min(x, i)
	a -= min(x, -1 * y)
print(a)


def meu_map(l):
	for i in range(len(l)):
		l[i] = int(l[i])

def f(n, array):
	impares = []
	primeiro = True
	maior_negativo = 0
	for i in range(len(array) - 1, -1, -1):
		if array[i] % 2 == 1 or array[i] % 2 == -1:
			if array[i] < 0:
				if primeiro:
					impares.append(array[i])
					break
				else:
					maior_negativo = array[i]
					break
			impares.append(array[i])
			primeiro = False
	soma = 0
	for e in impares:
		soma += e
	if soma % 2 == 0:
		if maior_negativo == 0:
			soma = soma - impares[-1]
		else:
			soma = max(soma + maior_negativo, soma - impares[-1])
	for i in range(len(array) - 1, -1, -1):
		if array[i] < 0:
			break
		if array[i] % 2 == 0:
			soma += array[i]
	return soma
n = int(input())
array = input().split()
meu_map(array)
array.sort()
print(f(n, array))


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : list(map(int, input().split()))
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
l = il()
dpeve = [0] * (n + 1)
dpodd = [0] * (n + 1)
if l[0] & 1:
	dpodd[0] = l[0]
	dpeve[0] = 0
else:
	dpeve[0] = l[0]
	dpodd[0] = -10 ** 10
for i in range(1, n):
	if l[i] & 1:
		dpodd[i] = max(l[i], dpodd[i - 1], dpeve[i - 1] + l[i])
		dpeve[i] = max(dpodd[i - 1] + l[i], dpeve[i - 1])
	else:
		dpodd[i] = max(l[i] + dpodd[i - 1], dpodd[i - 1])
		dpeve[i] = max(l[i], dpeve[i - 1], dpeve[i - 1] + l[i])
print(dpodd[n - 1])


from sys import stdin, stderr

def find(A):
	big = 0
	for i in range(len(A)):
		if A[i] > 0:
			big += A[i]
	if big % 2 == 1:
		return big
	else:
		minodd = 10 ** 10
		for i in range(len(A)):
			if A[i] % 2 == 1:
				if A[i] > 0 and A[i] < minodd:
					minodd = A[i]
		maxodd = -10 ** 10
		for i in range(len(A)):
			if A[i] % 2 == 1 and A[i] < 0:
				if A[i] > maxodd:
					maxodd = A[i]
		if minodd == 10 ** 10:
			return big + maxodd
		elif maxodd == -10 ** 10:
			return big - minodd
		else:
			return max(big - minodd, big + maxodd)
n = int(input())
A = list(map(int, input().strip().split(' ')))
print(find(A))


n = int(input())
l = sorted([int(i) for i in input().split()])
s = 0
c = -1
c1 = 0
c2 = 0
for i in range(n):
	if l[i] >= 0:
		s += l[i]
	else:
		c = i
if c < n - 1:
	if s % 2 == 1:
		print(s)
	else:
		for i in range(c, -1, -1):
			if l[i] % 2 == 1:
				k = l[i]
				c1 = 1
				break
		for i in range(c + 1, n):
			if l[i] % 2 == 1:
				k1 = l[i]
				c2 = 1
				break
		if c1 == 1 and c2 == 1:
			print(max(s + k, s - k1))
		elif c1 == 1:
			print(s + k)
		else:
			print(s - k1)
else:
	for i in range(n - 1, -1, -1):
		if l[i] % 2 == 1:
			k = l[i]
			break
	print(k)


gi = lambda : list(map(int, input().strip().split()))
gi()
l = gi()
ev = sorted([e for e in l if e % 2 == 0 and e > 0])
od = sorted([e for e in l if e % 2 == 1])
ans = od.pop() + sum(ev)
if len(od) % 2 == 1:
	od.remove(od[0])
while od and od[-2] > 0:
	ans += od.pop() + od.pop()
if od and od[-1] + od[-2] > 0:
	ans += od.pop() + od.pop()
print(ans)


n = int(input())
arr = [int(i) for i in input().split()]
s = 0
for i in range(n):
	if arr[i] > 0:
		s += arr[i]
if s % 2 != 0:
	print(s)
else:
	m = 100000
	for i in range(n):
		if arr[i] > 0 and arr[i] % 2 != 0:
			m = min(m, arr[i])
	ans = s - m
	for i in range(n):
		if arr[i] < 0 and arr[i] % 2 != 0:
			ans = max(ans, s + arr[i])
	print(ans)


a = int(input())
z = list(map(int, input().split()))
oddp = []
eve = []
oddn = []
for i in range(len(z)):
	if z[i] % 2 == 0 and z[i] > 0:
		eve.append(z[i])
	elif z[i] % 2 == 1:
		if z[i] > 0:
			oddp.append(z[i])
		else:
			oddn.append(z[i])
if len(oddp) == 0:
	print(max(oddn) + sum(eve))
elif len(oddp) % 2 == 1:
	print(sum(oddp) + sum(eve))
else:
	oddp.sort()
	if len(oddn) == 0:
		print(sum(oddp) - oddp[0] + sum(eve))
	elif len(oddp) == 0:
		print(min(oddn) + sum(eve))
	else:
		print(max(max(oddn) + sum(oddp), sum(oddp) - oddp[0]) + sum(eve))


n = int(input())
a = list(map(int, input().split()))
ans = int(0)
mx = int(-2000000000.0)
for i in a:
	if i > 0:
		ans += i
if ans % 2:
	print(ans)
else:
	for i in a:
		if i < 0 and i % 2:
			mx = max(mx, ans + i)
		if i > 0 and i % 2:
			mx = max(mx, ans - i)
	print(mx)


n = int(input())
li = list(map(int, input().split()))
(evensum, lis) = (0, [])
for i in li:
	if i > 0:
		evensum += i
	if i % 2 != 0:
		lis.append(abs(i))
print(evensum if evensum % 2 != 0 else evensum - min(lis))


n = input()
listt = list(map(int, input().strip().split()))
ans = 0
listt.sort()
pos = []
neg = []
for i in listt:
	if i > 0:
		ans += i
	if i % 2 == 1:
		if i > 0:
			pos.append(i)
		else:
			neg.append(i)
if ans % 2 == 1:
	print(ans)
else:
	if len(pos) == 0:
		ans += neg[-1]
	elif len(neg) == 0:
		ans -= pos[0]
	else:
		ans -= min(abs(neg[-1]), pos[0])
	print(ans)


import math

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

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

def li():
	return list(mi())
n = ii()
a = li()
a = sorted(a)
sum = 0
i = 0
for i in range(len(a) - 1, -1, -1):
	if a[i] < 0:
		break
	sum += a[i]
if sum % 2 == 1:
	print(sum)
	exit()
pos_odd = 1000000000
for j in range(i, len(a)):
	if a[j] > 0 and a[j] % 2 == 1:
		pos_odd = a[j]
		break
neg_odd = 1000000000
for j in range(i, -1, -1):
	if a[j] < 0 and (a[j] % 2 == 1 or a[j] % 2 == -1):
		neg_odd = a[j]
		break
print(sum + (neg_odd if abs(pos_odd) > abs(neg_odd) else -pos_odd))


n = int(input())
l = list(map(int, input().split()))
sum = 0
k = 0
for i in range(0, n):
	if l[i] > 0:
		sum += l[i]
		k = k + 1
if sum % 2 == 1:
	print(sum)
else:
	min = float('inf')
	if k >= 2:
		for i in range(0, n):
			if l[i] > 0 and l[i] < min and (l[i] % 2 != 0):
				min = l[i]
		for i in range(0, n):
			temp = -1 * l[i]
			if temp > 0 and temp < min and (temp % 2 != 0):
				min = temp
	else:
		for i in range(0, n):
			temp = -1 * l[i]
			if temp > 0 and temp < min and (l[i] % 2 != 0):
				min = temp
	print(sum - min)


import sys
n = int(sys.stdin.readline().strip())
integer_line = sys.stdin.readline().strip().split()
integers = []
for integer in integer_line:
	integers.append(int(integer))
max_odd = [None] * (len(integers) + 1)
max_even = [None] * (len(integers) + 1)
max_odd[-1] = 0
max_even[-1] = 0
for index in range(len(integers) - 1, -1, -1):
	if integers[index] % 2 == 0:
		max_even[index] = max(integers[index] + max_even[index + 1], max_even[index + 1])
		max_odd[index] = max(integers[index] + max_odd[index + 1], max_odd[index + 1])
		continue
	if max_odd[index + 1] % 2 == 0:
		max_even[index] = max_even[index + 1]
		max_odd[index] = max_even[index + 1] + integers[index]
		continue
	max_even[index] = max(integers[index] + max_odd[index + 1], max_even[index + 1])
	max_odd[index] = max(integers[index] + max_even[index + 1], max_odd[index + 1])
sys.stdout.write(str(max_odd[0]) + '\n')


n = int(input())
a = list(map(int, input().split()))
(s, en) = (0, 10001)
for x in a:
	if x > 0:
		s += x
	if x % 2 != 0:
		en = min(en, abs(x))
if s % 2 == 0:
	s -= en
print(s)


import math
import sys
from bisect import bisect_right, bisect_left, insort_right
from collections import Counter, defaultdict
from heapq import heappop, heappush
from itertools import accumulate
from sys import stdout
R = lambda : map(int, input().split())
n = int(input())
(odd, even) = ([], [])
for x in R():
	if x % 2:
		odd.append(x)
	else:
		even.append(x)
odd.sort()
even.sort()
io = bisect_right(odd, 0)
se = sum((max(x, 0) for x in even))
if io == len(odd):
	print(odd[-1] + se)
else:
	co = len(odd) - io
	if co % 2:
		print(sum(odd[io:]) + se)
	else:
		print(max(sum(odd[io + 1:]), sum(odd[io - 1:]) if io >= 1 else -math.inf) + se)


n = int(input())
a = [int(i) for i in input().split()]
mn = 20000
s = 0
for k in a:
	if k > 0:
		s += k
		if k % 2 == 1:
			mn = min(mn, k)
	elif k % 2 == 1:
		mn = min(mn, abs(k))
if s % 2 == 1:
	print(s)
else:
	print(s - mn)


n = int(input())
a = list(map(int, input().split()))
f = 0
for i in range(n):
	if a[i] >= 0:
		f += a[i]
if f % 2:
	print(f)
else:
	m = 10 ** 9
	for i in range(n):
		if a[i] % 2:
			m = min(m, abs(a[i]))
	print(f - m)


n = int(input())
a = list(map(int, input().split()))
oddSum = 0
evenSum = 0
smallPos = 10 ** 4 + 1
smallNeg = -10 ** 4 + 1
for i in range(n):
	if a[i] > 0:
		if a[i] % 2 == 0:
			evenSum += a[i]
		else:
			oddSum += a[i]
			smallPos = min(smallPos, a[i])
	elif a[i] % 2 == 1:
		smallNeg = max(smallNeg, a[i])
if oddSum == 0:
	print(smallNeg + evenSum)
elif oddSum % 2 == 1:
	print(oddSum + evenSum)
else:
	print(max(evenSum + oddSum - smallPos, evenSum + oddSum + smallNeg))


n = int(input())
nums = list(map(int, input().split()))
pos = [x for x in nums if x > 0]
neg = [x for x in nums if x < 0]
s1 = sum(pos)
if s1 % 2 == 1:
	print(s1)
	exit()
podd = [x for x in pos if x % 2 == 1]
nodd = [x for x in neg if x % 2 == 1]
if podd:
	min_podd = min(podd)
	if not nodd:
		s1 -= min_podd
	else:
		max_nodd = max(nodd)
		if min_podd + max_nodd > 0:
			s1 += max_nodd
		else:
			s1 -= min_podd
else:
	s1 += max(nodd)
print(s1)


import sys
import bisect
from bisect import bisect_left as lb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0

def hnbhai(tc):
	n = sb()
	a = sd()
	ss = 0
	for i in a:
		ss += i if i > 0 else 0
	if ss % 2 == 1:
		print(ss)
		return
	mn = float('inf')
	for i in a:
		if i % 2 == 1:
			mn = min(abs(i), mn)
	print(ss - mn)
for _ in range(1):
	hnbhai(_ + 1)


def LOS(L):
	sum1 = 0
	for i in range(len(L)):
		if L[i] > 0:
			sum1 = sum1 + L[i]
	if sum1 % 2 != 0:
		return sum1
	isodd = False
	min = 0
	for i in range(len(L)):
		if isodd == False and L[i] % 2 != 0:
			isodd = True
			min = L[i]
		elif isodd == True and L[i] % 2 != 0 and (abs(L[i]) < abs(min)):
			min = L[i]
	return sum1 - abs(min)
i = int(input(''))
L = [x for x in input('').split()]
for i in range(len(L)):
	L[i] = int(L[i])
print(LOS(L))


input()
s = input()
nums = s.split()
n = len(nums)
a = [0] * n
odd = list()
res = 0
for i in range(n):
	a[i] = int(nums[i])
	if a[i] % 2 == 1:
		odd.append(a[i])
	else:
		res += a[i] if a[i] > 0 else 0
odd.sort()
res += odd[-1]
for i in range(len(odd) - 2, 0, -2):
	if odd[i] + odd[i - 1] > 0:
		res += odd[i] + odd[i - 1]
	else:
		break
print(res)


n = int(input())
ar = list(map(int, input().split()))
odd = [i for i in ar if i % 2 == 1]
even = [i for i in ar if i % 2 == 0]
odd.sort(reverse=True)
even.sort(reverse=True)
sum_even = 0
for i in even:
	if i > 0:
		sum_even += i
preSum = []
preSum.append(odd[0])
for i in range(1, len(odd)):
	preSum.append(preSum[i - 1] + odd[i])
max_odd_sum = preSum[0]
for i in range(2, len(odd), 2):
	max_odd_sum = max(max_odd_sum, preSum[i])
print(max(max_odd_sum + sum_even, max_odd_sum))


def E():
	n = int(input())
	seq = [int(x) for x in input().split()]
	sum = 0
	min_odd = 10 ** 4
	for i in seq:
		if i > 0:
			sum += i
		if i % 2 == 1:
			if min_odd > abs(i):
				min_odd = abs(i)
	if sum % 2 == 0:
		sum = sum - min_odd
	print(sum)
E()


n = int(input())
a = list(map(int, input().split(' ')))
odd = [None] * n
even = [None] * n
is_odd = lambda x: True if x % 2 else False
if is_odd(a[0]):
	odd[0] = a[0]
else:
	even[0] = a[0]

def my_sum(a, b):
	if a is None:
		return b
	if b is None:
		return a
	return a + b

def my_max(*args):
	nn = list(filter(lambda x: x is not None, args))
	if len(nn):
		return max(nn)
	return None
for i in range(1, n):
	if is_odd(a[i]):
		odd[i] = my_max(my_sum(even[i - 1], a[i]), odd[i - 1], a[i])
		even[i] = my_max(odd[i - 1] + a[i] if odd[i - 1] is not None else None, even[i - 1])
	else:
		odd[i] = my_max(odd[i - 1] + a[i] if odd[i - 1] is not None else None, odd[i - 1])
		even[i] = my_max(my_sum(even[i - 1], a[i]), even[i - 1], a[i])
print(odd[-1])


n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
	if a[i] > 0:
		ans += a[i]
if ans % 2 != 0:
	print(ans)
else:
	x = [i for i in a if i % 2 != 0 and i < 0]
	y = [i for i in a if i % 2 != 0 and i > 0]
	x = sorted(x)
	y = sorted(y)
	if x and y:
		if abs(x[-1]) > abs(y[0]):
			print(ans - y[0])
		else:
			print(ans + x[-1])
	elif y:
		print(ans - y[0])
	elif x:
		print(ans + x[-1])
	else:
		print(-1)


from itertools import chain, compress, islice

def f(s):
	s = [int(x) for x in s.split(' ')]
	even = [x for x in s if x % 2 == 0 and x > 0]
	odd = [x for x in s if x % 2 == 1]
	odd.sort()
	odd.reverse()
	_sum = odd[0] if len(odd) else 0
	i = 1
	while i + 1 < len(odd):
		t_sum = odd[i] + odd[i + 1]
		if t_sum < 0:
			break
		_sum += t_sum
		i += 2
	return sum(even) + _sum
input()
print(f(input()))


def max_odd_subsequence():
	input()
	array = [int(x) for x in input().split()]
	sum = 0
	leastodd = 999999
	for i in array:
		if i > 0:
			sum += i
		if i % 2 == 1 and abs(i) < abs(leastodd):
			leastodd = i
	if sum % 2 == 1:
		return sum
	else:
		return sum - abs(leastodd)
print(max_odd_subsequence())


import bisect

def odd_sum(seq):
	result = 0
	min_pos_odd = False
	max_neg_odd = False
	for i in seq:
		if i < 0:
			if i % 2 == 1:
				if not bool(max_neg_odd) or i > max_neg_odd:
					max_neg_odd = i
		elif i % 2 == 0:
			result += i
		else:
			result += i
			if not bool(min_pos_odd) or i < min_pos_odd:
				min_pos_odd = i
	if result % 2 == 1:
		return result
	minus_pos_odd = False
	if bool(min_pos_odd):
		minus_pos_odd = result - min_pos_odd
	plus_neg_odd = False
	if bool(max_neg_odd):
		plus_neg_odd = result + max_neg_odd
	if not bool(minus_pos_odd):
		return plus_neg_odd
	elif not bool(plus_neg_odd):
		return minus_pos_odd
	if minus_pos_odd > plus_neg_odd:
		return minus_pos_odd
	return plus_neg_odd
n = int(input())
seq = [int(x) for x in input().split(' ')]
print(odd_sum(seq))


def solve(n, arr):
	ans = 0
	min_odd = float('inf')
	max_neg = float('-inf')
	for v in arr:
		if v < 0:
			if abs(v) % 2 == 1:
				max_neg = max(max_neg, v)
		else:
			ans += v
			if v % 2 == 1:
				min_odd = min(min_odd, v)
	if ans % 2 == 0:
		ans -= min(min_odd, -max_neg)
	print(ans)
n = int(input())
arr = list(map(int, input().split()))
solve(n, arr)


n = int(input().strip())
ais = list(map(int, input().strip().split()))

def solve(n, ais):
	s = sum((a for a in ais if a >= 0))
	if s % 2 == 1:
		return s
	maxoddneg = max([a for a in ais if a % 2 == 1 and a < 0], default=0)
	minoddpos = min([a for a in ais if a % 2 == 1 and a > 0], default=0)
	v = [-maxoddneg, minoddpos]
	v = [e for e in v if e != 0]
	return s - min(v)
res = solve(n, ais)
print(res)


n = int(input())
a = list(map(int, input().split()))
res = 0
new_a = []
for i in range(n):
	if a[i] % 2 == 0:
		if a[i] > 0:
			res += a[i]
	else:
		new_a.append(a[i])
a = new_a
a.sort()
res += a[-1]
a.pop()
while len(a) > 1:
	if a[-1] + a[-2] > 0:
		res += a[-1] + a[-2]
		a.pop()
		a.pop()
	else:
		break
print(res)


n = int(input())
li = list(map(int, input().split()))
(evensum, x, y) = (0, 999999999, -999999999)
for i in li:
	if i > 0:
		evensum += i
	if i > 0 and i % 2 != 0:
		x = min(x, i)
	if i < 0 and i % 2 != 0:
		y = max(y, i)
print(evensum if evensum % 2 != 0 else max(evensum - x, evensum + y))


import sys, math, queue
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)
n = int(input())
a = sorted(map(int, input().split()))
dp = [None for i in range(n)]
mxo = None
mxe = None
for i in range(n):
	if a[i] % 2 != 0:
		if mxe is None:
			if mxo is None:
				mxo = a[i]
			else:
				mxe = mxo + a[i]
				mxo = max(mxo, a[i])
		elif mxo is None:
			mxo = max(mxe + a[i], a[i])
		else:
			tmp = max(mxe + a[i], mxo, a[i])
			mxe = max(mxe, mxo + a[i])
			mxo = tmp
	elif mxe is None:
		if mxo is None:
			mxe = a[i]
		else:
			mxo = max(mxo + a[i], mxo)
			mxe = a[i]
	elif mxo is None:
		mxe = max(mxe, mxe + a[i], a[i])
	else:
		tmp = max(mxo + a[i], mxo)
		mxe = max(mxe, mxe + a[i], a[i])
		mxo = tmp
print(mxo)


from math import fabs

def solve():
	n = int(input())
	(ans, m) = (0, float('inf'))
	lst = list(map(int, input().split()))
	for val in lst:
		if val > 0:
			ans += val
		if val & 1:
			m = min(m, fabs(val))
	if not ans & 1:
		ans -= m
	ans = int(ans)
	print(ans if ans & 1 else -1)
solve()


n = int(input())
a = input()
A = list(map(int, list(a.split())))
e = [0] * n
o = [0] * n
if A[0] % 2 == 0:
	e[0] = A[0]
else:
	o[0] = A[0]
for i in range(1, n):
	if A[i] % 2 == 0:
		e[i] = max(A[i], A[i] + e[i - 1], e[i - 1])
		if o[i - 1] != 0:
			o[i] = max(A[i] + o[i - 1], o[i - 1])
		else:
			o[i] = o[i - 1]
	else:
		if o[i - 1] != 0:
			e[i] = max(A[i] + o[i - 1], e[i - 1])
		else:
			e[i] = e[i - 1]
		if o[i - 1] != 0:
			o[i] = max(A[i], A[i] + e[i - 1], o[i - 1])
		else:
			o[i] = max(A[i] + e[i - 1], A[i])
print(o[n - 1])


n = int(input())
a = list(map(int, input().split()))
s = 0
mi = 100000000
for i in a:
	if i > 0:
		s += i
	if i % 2 == 1:
		mi = min(mi, abs(i))
if s % 2 == 0:
	s -= mi
print(s)


n = int(input())
a = sorted(list(map(int, input().split())))
mx = max(a)
b = []
c = []
d = []
e = []
sum1 = 0
sum2 = 0
for i in range(n):
	if a[i] >= 0:
		sum1 += a[i]
		if a[i] % 2 == 0:
			b.append(a[i])
		else:
			c.append(a[i])
	else:
		sum2 += a[i]
		if a[i] % 2 == 0:
			d.append(a[i])
		else:
			e.append(a[i])
if sum1 % 2 == 1 and sum1 > 0:
	print(sum1)
elif len(e) > 0:
	if len(c) > 0:
		print(max(sum1 + e[-1], sum1 - c[0]))
	else:
		print(sum1 + e[-1])
elif len(c) > 0:
	print(sum1 - c[0])


n = int(input())
a = list(map(int, input().strip().split()))
c = 0
d = []
for i in range(n):
	if a[i] % 2 == 0:
		if a[i] > 0:
			c += a[i]
	else:
		d.append(a[i])
d.sort(reverse=True)
c += d[0]
i = 1
while i < len(d) - 1:
	if d[i] + d[i + 1] > 0:
		c += d[i] + d[i + 1]
		i += 2
	else:
		i = len(d)
print(c)


n = int(input())
a = [int(m) for m in input().split()]
b = []
ans = 0
for i in a:
	if i & 1:
		b.append(i)
	elif i > 0:
		ans += i
b.sort(reverse=True)
ans += b[0]
L = len(b)
for i in range(1, L, 2):
	if i + 1 >= L:
		break
	r = b[i] + b[i + 1]
	if r > 0:
		ans += r
	else:
		break
print(ans)


def makeodd(listt):
	c = 0
	for r in range(len(listt)):
		if listt[r] % 2 == 0:
			listt[r] = 'blah'
			c += 1
	for e in range(c):
		listt.remove('blah')
n = int(input())
inp = input()
nums = inp.split(' ')
for w in range(len(nums)):
	nums[w] = int(nums[w])
sum = 0
tsum = 0
neg = []
pos = []
an = False
noTroll = True
for i in range(n):
	if nums[i] > 0:
		sum += nums[i]
		pos.append(nums[i])
	elif nums[i] < 0:
		neg.append(nums[i])
if sum % 2 == 1:
	print(sum)
else:
	neg.sort()
	neg.reverse()
	pos.sort()
	makeodd(neg)
	makeodd(pos)
	z = 0
	while sum % 2 == 0 and noTroll:
		if len(pos) > z and len(neg) > z:
			if pos[z] % 2 != 0 and pos[z] < neg[z] * -1:
				sum -= pos[z]
				break
			elif neg[z] % 2 != 0:
				for q in range(len(pos) - z):
					if pos[q + z] > neg[z] * -1 and pos[q + z] % 2 != 0:
						an = True
						break
				if an:
					sum += neg[z]
					break
		elif len(neg) > z:
			if neg[z] % 2 != 0:
				sum += neg[z]
				break
		elif len(pos) > z:
			if pos[z] % 2 != 0:
				sum -= pos[z]
				break
		z += 1
	print(sum)


n = int(input())
l = list(map(int, input().split()))
nas = min(map(abs, filter(lambda n: n % 2 == 1, l)))
out = sum(filter(lambda n: n > 0, l))
if out % 2 == 0:
	print(out - nas)
else:
	print(out)


from sys import stdin

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

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

def li():
	return list(mi())
n = ii()
a = li()
(m, s, m1) = (-10010, 0, 10010)
for i in range(n):
	if a[i] > 0:
		s += a[i]
		if a[i] % 2:
			m1 = min(m1, a[i])
	elif a[i] % 2:
		m = max(m, a[i])
if not s % 2:
	if m1 > 10000:
		s += m
	elif m < -1000:
		s -= m1
	elif abs(m) < m1:
		s += m
	else:
		s -= m1
print(s)


n = int(input())
a = list(map(int, input().split()))
even = -float('Inf')
odd = -float('Inf')
for i in range(n):
	if a[i] % 2 == 0:
		even = max([even + a[i], a[i], even])
		odd = max([odd + a[i], odd])
	if a[i] % 2 != 0:
		(odd, even) = (max([even + a[i], odd, a[i]]), max([odd + a[i], even]))
if odd % 2 == 0:
	print(0)
else:
	print(odd)


n = int(input())
a = [int(i) for i in input().split()]
otrmax = -10 ** 4 - 1
polmin = 10 ** 4 + 1
sm = 0
for i in a:
	if i < 0:
		if i > otrmax and i % 2 == 1:
			otrmax = i
	else:
		if i < polmin and i % 2 == 1:
			polmin = i
		sm += i
if sm % 2 == 0:
	vrs = []
	if polmin != 10 ^ 4 + 1:
		vrs.append(sm - polmin)
	if otrmax != -10 ^ 4 - 1:
		vrs.append(sm + otrmax)
	print(max(vrs))
else:
	print(sm)


n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
	if l[i] >= 0:
		ans = ans + l[i]
if ans % 2 == 0:
	o = 10 ** 9
	for i in range(n):
		if abs(l[i]) % 2 == 1:
			o = min(o, abs(l[i]))
	print(ans - o)
else:
	print(ans)


n = int(input())
s = input()
s = s.split()
l = []
o = []
on = []
sum = 0
for i in s:
	te = int(i)
	l.append(te)
	if te > 0 and te % 2 == 1:
		o.append(te)
	elif te > 0 and te % 2 == 0:
		sum += te
	elif te < 0 and te % 2 == 1:
		on.append(te)
o.sort(reverse=True)
on.sort(reverse=True)
ko = 0
for i in on:
	if i % 2 == 1:
		ko = i
		break
j = 2
sumo = 0
if len(o) > 0:
	sumo = o[0]
while j < len(o):
	sumo += o[j] + o[j - 1]
	j += 2
if len(o) == 0:
	print(sum + ko)
elif len(o) % 2 == 1:
	print(sum + sumo)
elif len(o) % 2 == 0:
	if len(on) > 0 and ko < 0:
		print(max(sum + sumo, sum + sumo + ko + o[-1]))
	elif len(on) > 0 and ko == 0:
		print(sum + sumo)
	else:
		print(sum + sumo)


n = int(input())
max_even = -10002
max_odd = -10001
l = [int(x) for x in input().split()]
for i in l:
	if i % 2 == 1:
		(a, b) = (max(max_odd, i, max_even + i), max(max_even, max_odd + i))
		max_odd = a
		max_even = b
	else:
		(a, b) = (max(max_odd, max_odd + i), max(max_even, max_even + i, i))
		max_odd = a
		max_even = b
print(max_odd)


n = int(input())
ls = list(map(int, input().split()))
pos_sum = sum(list(filter(lambda x: x > 0, ls)))
ls = list(map(abs, ls))
ls = list(filter(lambda x: x % 2 != 0, ls))
if pos_sum % 2 != 0:
	print(pos_sum)
else:
	print(pos_sum - min(ls))


import sys

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

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

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr = get_array()
min_odd_pos = 10 ** 9
max_odd_neg = -10 ** 9
total = 0
for i in Arr:
	if i > 0:
		total += i
	if i > 0 and i & 1 and (i < min_odd_pos):
		min_odd_pos = i
	if i < 0 and i & 1 and (i > max_odd_neg):
		max_odd_neg = i
if total & 1:
	print(total)
else:
	print(total - min(min_odd_pos, -1 * max_odd_neg))


import sys
n = int(input())
A = list((int(i) for i in input().split()))
positiveeven = 0
positiveodd = 0
negativeeven = 0
negativeodd = 0
minpositiveodd = 10 ** 18
maxnnegativeodd = -10 ** 18
for i in range(n):
	if A[i] % 2 == 0:
		if A[i] >= 0:
			positiveeven += A[i]
		else:
			negativeeven += A[i]
	elif A[i] >= 0:
		positiveodd += A[i]
		minpositiveodd = min(A[i], minpositiveodd)
	else:
		maxnnegativeodd = max(A[i], maxnnegativeodd)
ans = positiveeven
if positiveodd % 2 != 0:
	ans += positiveodd
elif positiveodd > 0:
	ans1 = ans + positiveodd + maxnnegativeodd
	ans2 = ans + positiveodd - minpositiveodd
	ans = max(ans1, ans2)
else:
	ans += maxnnegativeodd
print(ans)


import sys
n = int(sys.stdin.readline())
l = list(map(int, sys.stdin.readline().split()))
pos = []
neg = []
for i in range(n):
	if l[i] < 0:
		neg.append(l[i])
	elif l[i] > 0:
		pos.append(l[i])
neg.sort(reverse=True)
pos.sort(reverse=True)
ans = 0
for i in range(len(pos)):
	if pos[i] % 2 == 0:
		ans += pos[i]
odd_pos = []
for i in range(len(pos)):
	if pos[i] % 2 == 1:
		odd_pos.append(pos[i])
odd_neg = []
for i in range(len(neg)):
	if neg[i] % 2 == 1:
		odd_neg.append(neg[i])
odd_neg.sort(reverse=True)
if len(odd_pos) > 0:
	if len(odd_pos) % 2 == 0:
		odd_pos.sort()
		for i in range(1, len(odd_pos)):
			ans += odd_pos[i]
		if len(odd_neg) > 0:
			if odd_pos[0] + odd_neg[0] > 0:
				ans += odd_pos[0] + odd_neg[0]
	else:
		ans += sum(odd_pos)
else:
	ans += odd_neg[0]
print(ans)


input()
l = list(map(int, input().split()))
pos = []
neg = []
for num in l:
	if num < 0:
		neg.append(num)
	else:
		pos.append(num)
neg.sort()
pos.sort()
total = sum(pos)
if total % 2 == 1:
	print(total)
else:
	lowest = 10 ** 10
	for num in pos:
		if num % 2 == 1 and num < lowest:
			lowest = num
	highest = -10 ** 10
	for num in neg:
		if -num % 2 == 1 and num > highest:
			highest = num
	temp = min(-highest, lowest)
	print(total - temp)


def OddSum(n, a):
	c = 0
	a.sort(reverse=True)
	i = 0
	minposodd = 99999
	maxnegodd = -99999
	while i < n:
		if a[i] > 0:
			c = c + a[i]
		if a[i] % 2 == 1:
			if a[i] > 0:
				minposodd = min(minposodd, a[i])
			else:
				maxnegodd = max(maxnegodd, a[i])
		i = i + 1
	if c % 2 == 1:
		return c
	if minposodd < abs(maxnegodd):
		c = c - minposodd
	else:
		c = c - abs(maxnegodd)
	return c
n = int(input())
a = list(map(int, input().rstrip().split()))
ans = OddSum(n, a)
print(ans)


le = int(input())
seq = input().split()
neg = -(10 ** 4 + 1)
odd = 0
z = 0
min_odd = 10 ** 4
for i in seq:
	if int(i) > 0 and int(i) % 2 == 0:
		z += int(i)
	elif int(i) > 0 and int(i) % 2 == 1:
		odd += int(i)
		if int(i) < min_odd:
			min_odd = int(i)
	elif int(i) < 0 and int(i) % 2 == 1:
		if neg < int(i):
			neg = int(i)
if (z + odd) % 2 == 1:
	print(z + odd)
else:
	print(odd + z - min(min_odd, -neg))


n = int(input())
lista = list(map(int, input().split()))
lista.sort()
par = []
impar = []
soma = 0
for i in range(n):
	if lista[i] % 2 == 0:
		if lista[i] > 0:
			soma += lista[i]
	else:
		impar += [lista[i]]
soma += impar[-1]
j = len(impar) - 2
while j >= 1:
	if impar[j] + impar[j - 1] > 0:
		soma += impar[j] + impar[j - 1]
		j -= 2
	else:
		break
print(soma)


import sys
import math
n = int(input())
a = list(map(int, input().split()))
even = 0
odds = []
for i in range(n):
	if a[i] % 2 == 0 and a[i] > 0:
		even += a[i]
	elif a[i] % 2 == 1:
		odds.append(-a[i])
odds.sort()
maxsum = -odds[0]
i = 1
cursum = -odds[0]
while i < len(odds):
	cursum += -odds[i]
	i += 1
	if i >= len(odds):
		break
	cursum += -odds[i]
	i += 1
	maxsum = max(maxsum, cursum)
print(maxsum + even)


n = int(input())
arr = [int(x) for x in input().split()]
even = []
odd = []
odd_n = []
s = 0
for i in arr:
	if i > 0:
		s += i
		if i % 2:
			odd.append(i)
		else:
			even.append(i)
	elif i % 2:
		odd_n.append(i)
if s % 2:
	print(s)
else:
	if len(odd) > 0 and len(odd_n) > 0:
		s = max(s - min(odd), s + max(odd_n))
	elif len(odd) > 0:
		s = s - min(odd)
	else:
		s += max(odd_n)
	print(s)


import sys
input = sys.stdin.readline
n = int(input())
a = [int(x) for x in input().split(' ')]
dp = [(0, -float('inf'))]
for i in range(n):
	if a[i] % 2 == 0:
		dp.append((max(a[i], 0) + dp[-1][0], max(a[i], 0) + dp[-1][1]))
	else:
		dp.append((max(dp[-1][0], dp[-1][1] + a[i]), max(dp[-1][1], dp[-1][0] + a[i])))
print(dp[-1][1])


n = int(input())
a = list(map(int, input().split()))
s = 0
neg = -10000
pos = 10000
for i in range(n):
	if a[i] % 2:
		if a[i] < 0:
			neg = max(a[i], neg)
		else:
			pos = min(a[i], pos)
	if a[i] > 0:
		s += a[i]
if neg % 2 == 0:
	neg = 10000
if pos % 2 == 0:
	pos = 10000
if s % 2 == 0:
	s -= min(abs(neg), pos)
print(s)


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()
ep = 0
en = 0
po = 10 ** 10
no = 10 ** 10
for i in range(n):
	if l[i] > 0 and l[i] % 2 == 0:
		ep += l[i]
	if l[i] < 0 and l[i] % 2 == 0:
		en = min(en, l[i])
	if l[i] > 0 and l[i] % 2 == 1:
		po = min(po, l[i])
		ep += l[i]
		f = 1
	if l[i] < 0 and l[i] % 2 == 1:
		no = min(no, abs(l[i]))
if ep % 2 == 1:
	print(ep)
else:
	key = 10 ** 10
	if po != 10 ** 10:
		key = po
	if no != -10 ** 10:
		key = min(no, key)
	if key != 10 ** 10:
		print(ep - key)


n = int(input())
nums = [int(i) for i in input().split()]
result = 0
min_positive = 10001
max_negative = -10001
for i in nums:
	if i > 0:
		result += i
	if i % 2 == 1:
		if 0 < i < min_positive:
			min_positive = i
		elif max_negative < i < 0:
			max_negative = i
if result % 2 == 0:
	if abs(max_negative) > min_positive:
		result -= min_positive
	else:
		result += max_negative
print(result)


n = int(input())
a = list(map(int, input().split()))
even = []
odd = []
for i in a:
	if i & 1:
		odd.append(i)
	else:
		even.append(i)
odd.sort(reverse=True)
even.sort(reverse=True)
ans = 0
for i in even:
	if i < 0:
		break
	ans += i
ocount = 0
for i in range(len(odd)):
	if odd[i] >= 0:
		ans += odd[i]
		ocount += 1
	elif odd[i] < 0 and (not ocount & 1):
		if ocount == 0:
			ans += odd[i]
			break
		elif odd[i - 1] < abs(odd[i]):
			ans -= odd[i - 1]
			break
		else:
			ans += odd[i]
			break
if not ans & 1:
	ans -= odd[-1]
print(ans)


import heapq
n = int(input())
a = list(map(int, input().split()))
valut = [0 in range(n)]
ans = 0
ret = []
plus = []
minus = []
for v in a:
	if v > 0:
		ans += v
		heapq.heappush(plus, v)
	elif v < 0:
		heapq.heappush(minus, abs(v))
if ans & 1:
	print(ans)
else:
	remove = 0
	while len(plus) > 0 and remove % 2 == 0:
		remove = heapq.heappop(plus)
	if remove & 1:
		ret.append(ans - remove)
	remove = 0
	while len(minus) > 0 and remove % 2 == 0:
		remove = heapq.heappop(minus)
	if remove & 1:
		ret.append(ans - remove)
	print(max(ret))


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from itertools import combinations, permutations
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
n = ii()
arr = rr()
a = list([i for i in arr if i > 0])
b = list([i for i in arr if i < 0 and i % 2])
c = sum(a)
if c % 2:
	print(c)
else:
	x = [i for i in a if i % 2]
	if not x:
		print(c + max(b))
	elif not b:
		print(c - min(x))
	else:
		o = c - min(x)
		p = c + max(b)
		print(max(o, p))


N = int(input())
A = list(map(int, input().split()))
dp = [[-int(1000000000.0) for i in range(2)] for j in range(N + 1)]
dp[0][0] = 0
for i in range(N):
	for j in range(2):
		if abs(A[i]) & 1:
			dp[i + 1][j] = max(dp[i][j], dp[i][j ^ 1] + A[i])
		else:
			dp[i + 1][j] = max(dp[i][j], dp[i][j] + A[i])
print(dp[N][1])


from math import inf
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
m = inf
s = 0
q = 'a'
for i in a:
	if i > 0:
		s += i
		if i % 2 == 1:
			m = min(m, i)
	if i < 0:
		if i % 2 == 1:
			q = i
if s % 2 == 1:
	print(s)
elif q == 'a':
	print(s - m)
else:
	print(max(s - m, s + q))


_ = input()
v = [int(x) for x in input().split()]
neg_par = []
neg_impar = []
poz_par = []
poz_impar = []
for x in v:
	if x < 0:
		if x % 2 == 0:
			neg_par.append(x)
		else:
			neg_impar.append(x)
	elif x % 2 == 0:
		poz_par.append(x)
	else:
		poz_impar.append(x)
neg_par.sort()
neg_impar.sort()
poz_par.sort()
poz_impar.sort()
res = sum(poz_par)
if len(poz_impar) > 0:
	if len(poz_impar) % 2 == 1:
		res += sum(poz_impar)
	elif len(neg_impar) > 0 and neg_impar[-1] + poz_impar[0] > 0:
		res += sum(poz_impar)
		res += neg_impar[-1]
	else:
		res += sum(poz_impar[1:])
else:
	res += neg_impar[-1]
print(res)


n = int(input())
a = list(map(int, input().split()))
pe = []
po = []
ne = []
no = []
for i in range(n):
	if a[i] > 0 and a[i] % 2 == 0:
		pe.append(a[i])
	if a[i] > 0 and a[i] % 2 != 0:
		po.append(a[i])
	if a[i] < 0 and a[i] % 2 == 0:
		ne.append(a[i])
	if a[i] < 0 and a[i] % 2 != 0:
		no.append(a[i])
if (sum(pe) + sum(po)) % 2 != 0:
	print(sum(pe) + sum(po))
else:
	b = []
	if len(no) > 0:
		b.append(sum(pe) + sum(po) + max(no))
	if len(po) > 0:
		b.append(sum(pe) + sum(po) - min(po))
	print(max(b))


n = int(input())
A = list(map(int, input().split()))
p = []
m = []
for a in A:
	if a > 0:
		p.append(a)
	elif a < 0 and a % 2:
		m.append(a)
if p:
	p.sort()
	sm = sum(p)
else:
	sm = 0
if sm % 2:
	print(sm)
	exit()
pcand = float('inf')
if m:
	mcand = max(m)
else:
	mcand = -float('inf')
for pp in p:
	if pp % 2:
		pcand = pp
		break
print(max(sm - pcand, sm + mcand))


from collections import Counter, defaultdict, deque
import heapq as hq
from itertools import count, islice
import math
import sys
input = sys.stdin.readline
n = int(input())
arr = [int(x) for x in input().split()]
pos = []
neg = []
s = 0
for i in range(n):
	if arr[i] > 0:
		pos.append(arr[i])
		s += arr[i]
	else:
		neg.append(arr[i])
if s % 2:
	print(s)
else:
	pos.sort()
	neg.sort(reverse=True)
	mp = 10 ** 9
	mn = -10 ** 9
	for el in pos:
		if el % 2:
			mp = el
			break
	for el in neg:
		if el % 2:
			mn = el
			break
	print(s - min(mp, -mn))


n = int(input())
a = list(map(int, input().split()))
a.sort()
b = []
c = []
for i in range(n):
	if a[i] >= 0:
		b = a[i:]
		break
	c.append(a[i])
r = sum(b)
c = c[::-1]
if r % 2 != 0:
	print(r)
else:
	m = k = -10000000000.0
	for i in b:
		if (r - i) % 2 != 0:
			k = r - i
			break
	for i in c:
		if (r + i) % 2 != 0:
			m = r + i
			break
	print(max(m, k))


n = int(input())
a = [int(i) for i in input().split()]
sp = 0
for i in a:
	if i >= 0:
		sp += i
if sp % 2 == 1:
	print(sp)
else:
	v = list(filter(lambda x: x > 0 and x % 2 == 1, a))
	if len(v) == 0:
		sm = -1000000000.0
	else:
		sm = sp - min(v)
	for i in a:
		if i < 0 and i % 2 == 1:
			sm = max(sp + i, sm)
	print(sm)


n = int(input())
a = list(map(int, input().split(' ')))
s = 0
od = []
od_neg = []
for i in range(n):
	if a[i] > 0:
		s += a[i]
	if a[i] > 0 and a[i] % 2:
		od.append(a[i])
	elif a[i] < 0 and a[i] % 2:
		od_neg.append(a[i])
od.sort()
od_neg.sort()
if s % 2:
	print(s)
elif od and od_neg:
	print(max(s - od[0], s + od_neg[-1]))
elif od:
	print(s - od[0])
elif od_neg:
	print(s + od_neg[-1])
else:
	print(0)


n = int(input())
arr = list(map(int, input().strip().split()))
minOddPos = float('inf')
minOddNeg = -float('inf')
posSumi = 0
for i in arr:
	if i > 0:
		if i % 2:
			minOddPos = min(minOddPos, i)
		posSumi += i
	elif i % 2:
		minOddNeg = max(minOddNeg, i)
if posSumi > 0:
	if posSumi % 2:
		print(posSumi)
	elif minOddNeg != -float('inf') and minOddPos != float('inf'):
		print(posSumi - min(abs(minOddNeg), minOddPos))
	elif minOddNeg != -float('inf'):
		print(posSumi + minOddNeg)
	else:
		print(posSumi - minOddPos)
else:
	print(minOddNeg)


k = int(input())
liste = list(map(int, input().split()))
x = 0
list1 = []
for i in liste:
	if i > 0:
		x += i
if x % 2:
	print(x)
else:
	for i in liste:
		if i % 2:
			list1.append(abs(i))
	print(x - min(list1))


n = int(input())
t = list(map(int, input().split()))
s = sum((i for i in t if i > 0))
if s % 2:
	print(s)
else:
	m = [abs(i) for i in t if i % 2 == 1]
	print(s - min(m))


n = int(input())
a = list(map(int, input().split(' ')))
minus_odd = -10001
plus_odd = 10001
total = 0
for i in a:
	if i % 2:
		if i < 0:
			minus_odd = max(minus_odd, i)
		else:
			plus_odd = min(plus_odd, i)
	if i > 0:
		total += i
if total % 2 == 0:
	if minus_odd == -10001:
		print(total - plus_odd)
	elif plus_odd == 10001:
		print(total + minus_odd)
	elif -minus_odd > plus_odd:
		print(total - plus_odd)
	else:
		print(total + minus_odd)
else:
	print(total)


input()
a = list(map(int, input().split()))
s = 0
(p, n) = ([i for i in a if i > 0], [j for j in a if j < 0])
s = sum(p)
if s % 2 == 1:
	print(s)
else:
	m = -10000000
	for x in sorted(n)[::-1]:
		if x % 2 == 1:
			m = x
			break
	for y in sorted(p):
		if y % 2 == 1:
			m = max(m, -y)
	print(s + m)


n = int(input())
lis = list(map(int, input().split()))
odd_sum = 0
alis = []
for i in lis:
	if i > 0:
		odd_sum += i
if odd_sum % 2 != 0:
	print(odd_sum)
else:
	for i in lis:
		if i % 2 != 0:
			alis.append(abs(i))
	print(odd_sum - min(alis))


N = int(input())
A = [int(i) for i in input().split()]
try:
	minposodd = min((a for a in A if a > 0 and a % 2))
except ValueError:
	minposodd = None
try:
	maxnegodd = max((a for a in A if a < 0 and a % 2))
except ValueError:
	maxnegodd = None
sm = sum((a for a in A if a > 0))
if sm % 2:
	print(sm)
else:
	best = float('-inf')
	if minposodd is not None:
		best = sm - minposodd
	if maxnegodd is not None:
		best = max(best, sm + maxnegodd)
	print(best)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	ans = sum((x for x in a if x > 0))
	if ans % 2 == 1:
		print(ans)
		return
	c = None
	for x in a:
		if x % 2 == 1:
			if c is None:
				c = abs(x)
			else:
				c = min(c, abs(x))
	print(ans - c)
main()


len = int(input())
a = list(map(int, input().split()))
a.sort()
sum = 0
for i in range(len):
	if a[~i] < 0:
		break
	sum += a[~i]
if sum % 2 == 1:
	print(sum)
	exit()
a = sorted(list(map(abs, a)))
for i in range(len):
	if a[i] % 2 == 1:
		sum -= a[i]
		break
print(sum)


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import PriorityQueue as pq
n = int(input())
l = list(map(int, input().split()))
m = sys.maxsize
s = 0
p = 0
c = 0
t = -1 * sys.maxsize
for i in l:
	if i > 0:
		if i % 2 == 1:
			c += 1
			s += i
			m = min(m, i)
		else:
			p += i
	elif i % 2 == 1:
		t = max(t, i)
if c > 0:
	if s % 2:
		print(s + p)
	else:
		print(max(s - m + p, s + t + p))
else:
	s = 0
	c = 0
	m = -1 * sys.maxsize
	for i in l:
		if i < 0:
			if i % 2:
				c += 1
				m = max(m, i)
		elif i % 2 == 0:
			s += i
	if c == 0:
		print(0)
	else:
		print(s + m)


n = int(input())
a = list(map(int, input().split()))
c = list(filter(lambda x: x % 2 == 0 and x > 0, a))
b = list(filter(lambda x: x % 2 != 0, a))
b = sorted(b, reverse=True)
mm = int(-10000000000.0)
s = 0
for i in range(len(b)):
	s += b[i]
	if i % 2 == 0:
		mm = max(mm, s)
print(sum(c) + mm)


import sys
import collections

def main():
	n = int(sys.stdin.readline())
	v = list(map(int, sys.stdin.readline().split()))
	ans = [0 for i in range(len(v))]
	best = -100000
	sum_odd = -100000
	sum_even = 0
	for i in range(len(v)):
		if v[i] & 1:
			best = max(best, sum_even + v[i])
			(sum_odd, sum_even) = (max(max(sum_odd, v[i]), sum_even + v[i]), max(max(sum_even, 0), sum_odd + v[i]))
		else:
			best = max(best, sum_odd + v[i])
			(sum_odd, sum_even) = (max(sum_odd, sum_odd + v[i]), max(max(sum_even, v[i]), sum_even + v[i]))
	print(best)
main()


n = int(input())
l = list(map(int, input().split(' ')))
l_even = []
l_odd = []
for i in l:
	if i % 2 == 0:
		if i > 0:
			l_even.append(i)
	else:
		l_odd.append(i)
sum_even = sum(l_even)
l_odd.sort()
countt = 0
index = -999
tt = 0
l2 = []
for i in range(len(l_odd)):
	if l_odd[i] < 0:
		index = i
	if l_odd[i] > 0:
		countt += 1
		l2.append(l_odd[i])
if countt == 0:
	print(sum_even + l_odd[index])
elif countt % 2 != 0:
	print(sum_even + sum(l2))
elif countt % 2 == 0:
	if index == -999 or l2[0] <= abs(l_odd[index]):
		del l2[0]
		print(sum_even + sum(l2))
	elif l2[0] > abs(l_odd[index]):
		print(sum_even + sum(l2) + l_odd[index])


n = int(input())
A = list(map(int, input().split()))
sumpos = 0
maxoddneg = 100000000
minoddpos = 100000000
for i in A:
	if i > 0:
		sumpos += i
		if i % 2:
			minoddpos = min(minoddpos, i)
	elif i % 2:
		maxoddneg = min(-i, maxoddneg)
if sumpos % 2:
	print(sumpos)
else:
	print(sumpos - min(minoddpos, maxoddneg))


n = int(input())
arr = list(map(int, input().split()))
max_odd_neg = -1000000000.0
for i in arr:
	if i < 0 and i % 2 == 1:
		max_odd_neg = max(max_odd_neg, i)
min_pos_odd = 1000000000.0
for i in arr:
	if i > 0 and i % 2 == 1:
		min_pos_odd = min(min_pos_odd, i)
s = 0
for i in arr:
	if i > 0:
		s += i
if s % 2 == 1:
	print(s)
else:
	print(max(s - min_pos_odd, s + max_odd_neg))


import math
n = list(map(int, input().split()))
alist = list(map(int, input().split()))
sumpos = 0
maxNegOdd = -1000000000.0
maxPosODD = 1000000000.0
for i in alist:
	if i > 0:
		sumpos += i
		if i < maxPosODD and i % 2 != 0:
			maxPosODD = i
	elif i % 2 != 0 and maxNegOdd < i:
		maxNegOdd = i
if sumpos % 2 == 0:
	if maxPosODD > abs(maxNegOdd):
		sumpos += maxNegOdd
	else:
		sumpos -= maxPosODD
print(sumpos)


n = int(input())
l = list(map(int, input().split()))
op = float('inf')
on = float('-inf')
flag1 = 0
flag2 = 0
sum = 0
for i in l:
	if i > 0:
		sum += i
	if i % 2 != 0 and i > 0:
		flag1 = 1
		op = min(op, i)
	elif i % 2 != 0 and i < 0:
		flag2 = 1
		on = max(on, i)
if flag1 == 0:
	op = 0
if flag2 == 0:
	on = 0
if sum == 0:
	ans = on
elif sum % 2 != 0:
	ans = sum
elif op != 0 and on != 0:
	ans = max(sum - op, sum + on)
elif op != 0:
	ans = sum - op
elif on != 0:
	ans = sum + on
print(ans)


n = int(input())
arr = list(map(int, input().strip().split()))
m = 2 ** 31
res = 0
odd = False
for i in range(n):
	if arr[i] > 0:
		res += arr[i]
	if arr[i] % 2 != 0:
		odd = True
		m = min(m, abs(arr[i]))
if not odd:
	print(-1)
else:
	if res % 2 == 0:
		res -= m
	print(res)


from math import inf
n = int(input())
a = [int(i) for i in input().split()]
odd = [-inf for i in range(n)]
even = [-inf for i in range(n)]
if a[0] % 2 == 0:
	even[0] = a[0]
else:
	odd[0] = a[0]
max_even = even[0]
max_odd = odd[0]
for i in range(1, n):
	if a[i] % 2 == 0:
		even[i] = max(a[i], max_even + a[i])
		odd[i] = max_odd + a[i]
	else:
		even[i] = max_odd + a[i]
		odd[i] = max(a[i], max_even + a[i])
	max_even = max(max_even, even[i])
	max_odd = max(max_odd, odd[i])
print(max(odd))


n = int(input())
a = list(map(int, input().split()))
odd = []
oddp = []
even = []
for i in a:
	if i % 2 == 0:
		if i > 0:
			even.append(i)
	elif i > 0:
		oddp.append(i)
	else:
		odd.append(i)
odd = sorted(odd)
oddp = sorted(oddp)
s = sum(even)
if len(oddp) > 0:
	if len(oddp) % 2 != 0:
		print(sum(oddp) + s)
	elif len(odd) == 0:
		print(sum(oddp) - oddp[0] + s)
	else:
		print(max(sum(oddp) - oddp[0], sum(oddp) + odd[-1]) + s)
else:
	print(s + odd[-1])


import math
from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
even = [0] * n
odd = [-math.inf] * n
if arr[0] % 2:
	odd[0] = arr[0]
else:
	even[0] = arr[0]
for i in range(1, n):
	if arr[i] % 2 == 1:
		odd[i] = max(even[i - 1] + arr[i], odd[i - 1], arr[i])
		even[i] = max(odd[i - 1] + arr[i], even[i - 1])
	else:
		even[i] = max(even[i - 1], even[i - 1] + arr[i], arr[i])
		odd[i] = max(odd[i - 1] + arr[i], odd[i - 1])
print(odd[-1])


n = int(input())
numbers = [int(i) for i in input().split()]
l = 0
r = 0
positive = [i for i in numbers if i >= 0]
negative = [i for i in numbers if i < 0]
sumT = sum(positive)
negative.sort(reverse=True)
positive.sort()
imparPositivo = 0
flag = False
for v in positive:
	if v % 2 == 1:
		flag = True
		imparPositivo = v
		break
if sumT % 2 != 1:
	for i in range(len(negative)):
		if negative[i] % 2 == 1:
			if flag:
				sumT -= min(imparPositivo, -negative[i])
			else:
				sumT += negative[i]
			flag = False
			break
	if flag:
		sumT -= imparPositivo
print(sumT)


n = int(input())
x = list(map(int, input().split()))
odd_cnt = []
ans = 0
for i in range(n):
	if x[i] % 2 == 0 and x[i] > 0:
		ans += x[i]
	elif x[i] % 2 != 0:
		odd_cnt.append(x[i])
odd_cnt.sort(reverse=True)
for j in range(len(odd_cnt)):
	if j == 0 and odd_cnt[j] < 0:
		ans += odd_cnt[j]
	elif odd_cnt[j] < 0 and ans % 2 == 0:
		if abs(odd_cnt[j]) > odd_cnt[j - 1]:
			ans -= odd_cnt[j - 1]
		else:
			ans += odd_cnt[j]
		break
	elif len(odd_cnt) % 2 == 0:
		if j == len(odd_cnt) - 1:
			break
		elif odd_cnt[j] > 0:
			ans += odd_cnt[j]
		else:
			if j % 2 == 0:
				ans -= odd_cnt[j - 1]
			break
	elif len(odd_cnt) % 2 != 0:
		if odd_cnt[j] > 0:
			ans += odd_cnt[j]
		else:
			if ans % 2 == 0:
				ans -= odd_cnt[j - 1]
			break
	if j == len(odd_cnt) - 1 and ans % 2 == 0:
		ans -= odd_cnt[j]
print(ans)


from sys import maxsize, stdout, stdin, stderr
import re
tup = lambda : map(int, stdin.readline().split())
I = lambda : int(stdin.readline())
lint = lambda : [int(x) for x in stdin.readline().split()]
S = lambda : stdin.readline().replace('\n', '').strip()

def grid(r, c):
	return [lint() for i in range(r)]

def debug(*args, c=6):
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=stderr)
stpr = lambda x: stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
from math import ceil
from collections import defaultdict
from itertools import permutations
n = I()
ls = lint()
odp = maxsize
odn = maxsize
s = 0
for i in ls:
	if i > 0:
		s += i
		if i % 2:
			odp = min(odp, i)
	elif i % 2:
		odn = min(odn, -i)
if s % 2:
	print(s)
else:
	print(s - min(odp, odn))


n = int(input())
l = list(map(int, input().split()))
odd_pos = []
odd_neg = []
even_pos = []
even_neg = []
for i in range(len(l)):
	if l[i] % 2 == 1 and l[i] > 0:
		odd_pos.append(l[i])
	elif l[i] % 2 == 0 and l[i] > 0:
		even_pos.append(l[i])
	elif l[i] % 2 == 1 and l[i] < 0:
		odd_neg.append(l[i])
	else:
		even_neg.append(l[i])
if len(odd_pos):
	odd_pos.sort(reverse=True)
	if len(odd_pos) % 2 == 0:
		if len(odd_neg):
			t = max(odd_pos[-1] + max(odd_neg), 0)
		else:
			t = 0
		odd_pos = odd_pos[:len(odd_pos) - 1]
		ans1 = sum(odd_pos) + t
	else:
		ans1 = sum(odd_pos)
	if len(even_pos):
		ans2 = sum(even_pos)
	else:
		ans2 = 0
	print(ans1 + ans2)
elif len(odd_neg):
	ans1 = max(odd_neg)
	if len(even_pos):
		ans2 = sum(even_pos)
	else:
		ans2 = 0
	print(ans1 + ans2)


n = int(input())
lis = list(map(int, input().split()))
pe = []
po = []
ne = []
no = []
for i in lis:
	if i > 0 and i % 2:
		po.append(i)
	elif i > 0 and i % 2 == 0:
		pe.append(i)
	elif i < 0 and i % 2:
		no.append(i)
	else:
		ne.append(i)
po.sort()
pe.sort()
no.sort()
ne.sort()
if len(po) >= 1 and len(po) % 2:
	print(sum(po) + sum(pe))
elif len(po) >= 1 and len(po) % 2 == 0:
	aa = sum(pe) + sum(po[1:])
	bb = 0
	if len(no) >= 1:
		bb = sum(pe) + sum(po) + no[-1]
	print(max(aa, bb))
else:
	print(sum(pe) + no[-1])


from sys import exit
negative = []
positive = []
n = int(input())
total = 0
for i in input().split():
	a = int(i)
	if a > 0:
		positive.append(a)
		total += a
	else:
		negative.append(-a)
if total % 2 == 1:
	print(total)
	exit(0)
positive.sort()
negative.sort()
a1 = 10000007
a2 = 10000007
for i in range(0, len(positive)):
	if positive[i] % 2 == 1:
		a1 = positive[i]
		break
for i in range(0, len(negative)):
	if negative[i] % 2 == 1:
		a2 = negative[i]
		break
if a1 < a2:
	print(total - a1)
else:
	print(total - a2)


tam = int(input())
numeros = [*map(int, input().split())]
intMax = 1000000
soma = 0
m = intMax
for e in numeros:
	if e > 0:
		soma += e
	if e % 2 != 0:
		m = min(m, abs(e))
if soma % 2 == 0:
	soma -= m
print(soma)


n = int(input())
lst = [int(x) for x in input().split(' ')]
even = list(filter(lambda x: x % 2 == 0, lst))
odd = list(filter(lambda x: x % 2 != 0, lst))
even_sum = 0
for i in even:
	if i > 0:
		even_sum += i
odd = reversed(sorted(odd))
possible = []
rolling = 0
for i in odd:
	rolling += i
	possible.append(even_sum + rolling)
possible = reversed(sorted(possible))
for i in possible:
	if i % 2 != 0:
		print(i)
		break


import sys
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue
from math import *
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
mod = 10 ** 9 + 7
n = ii()
a = il()
s = 0
for i in a:
	if i > 0:
		s += i
if s % 2 == 1:
	print(s)
	exit(0)
mi = float('inf')
for i in a:
	if i % 2 == 1:
		mi = min(mi, abs(i))
print(s - mi)


import math
import queue
from itertools import permutations
n = int(input())
a = [int(cost) for cost in input().split()]
smallest_positive_odd = 1000001
largest_negative_odd = -1000001
pos_sum = 0
for i in range(0, n):
	if a[i] >= 0:
		pos_sum += a[i]
		if a[i] % 2 == 1 and a[i] < smallest_positive_odd:
			smallest_positive_odd = a[i]
	elif a[i] % 2 == 1 and a[i] > largest_negative_odd:
		largest_negative_odd = a[i]
if pos_sum % 2 == 1:
	answer = pos_sum
else:
	answer = max(pos_sum + largest_negative_odd, pos_sum - smallest_positive_odd)
print(answer)


n = int(input())
array = list(map(int, input().split()))
array.sort()
array.reverse()
odd = 0
odde = []
for k in range(n):
	if array[k] % 2 == 0 and array[k] > 0:
		odd += array[k]
	elif array[k] % 2 == 1:
		odde.append(array[k])
odd += odde[0]
m = len(odde)
i = 2
while m - i > 0:
	if odde[i - 1] + odde[i] > 0:
		odd += odde[i - 1] + odde[i]
	i += 2
print(odd)


n = int(input())
arr = list(map(int, input().split()))
res = sum(filter(lambda x: x > 0, arr))
if res & 1 == 0:
	delta = abs(min(filter(lambda x: x & 1, arr), key=abs))
	res -= delta
print(res)


n = int(input())
arr = list(map(int, input().split()))
s = 0
mi = 10000
for i in range(n):
	if arr[i] > 0:
		s += arr[i]
	if abs(arr[i]) < mi and arr[i] % 2 != 0:
		mi = abs(arr[i])
if s % 2 == 0:
	print(s - mi)
else:
	print(s)


import sys
n = int(input())
x = list(map(int, input().strip().split()))[:n]
sum = 0
for i in x:
	if i > 0:
		sum += i
if sum % 2 == 1:
	print(sum)
else:
	sum1 = sum
	ans1 = -sys.maxsize
	for i in x:
		if i < 0 and i % 2 == 1:
			ans1 = max(ans1, i)
	sum1 += ans1
	sum2 = sum
	ans2 = sys.maxsize
	for i in x:
		if i > 0 and i % 2 == 1:
			ans2 = min(ans2, i)
	sum2 -= ans2
	print(max(sum1, sum2))


n = int(input())
a = list(map(int, input().split()))
sum = 0
min_odd = 10001
for x in a:
	if x > 0:
		sum += x
	if x % 2 != 0:
		min_odd = min(abs(x), min_odd)
if sum % 2 != 1:
	sum -= min_odd
print(sum)


_ = int(input())
a = list(map(int, input().split()))
r = sum([i for i in a if 0 < i])
if r % 2 == 1:
	print(r)
else:
	print(max(r + max([i for i in a if i % 2 == 1 and i < 0], default=-10 ** 12), r - min([i for i in a if i % 2 == 1 and 0 < i], default=10 ** 12)))


n = int(input())
a = list(map(int, input().split()))
(codd, odd, even) = (0, 0, 0)
modd = 0
Modd = 10 ** 5
K = -10 ** 5
for i in range(n):
	if a[i] > 0:
		if a[i] % 2 == 0:
			even += a[i]
		if a[i] % 2 == 1:
			odd += a[i]
			modd = max(modd, a[i])
			Modd = min(Modd, a[i])
			codd += 1
	elif a[i] % 2 == 1:
		K = max(K, a[i])
if codd % 2 == 1:
	print(odd + even)
else:
	print(even + odd - min(Modd, -K))


n = int(input())
a = list(map(int, input().split()))
s = 0
p = 99999999
q = -9999999
for i in range(n):
	if a[i] > 0:
		s += a[i]
	if a[i] < 0 and a[i] > q and (a[i] % 2 != 0):
		q = a[i]
	if a[i] > 0 and a[i] < p and (a[i] % 2 != 0):
		p = a[i]
if s % 2 == 0:
	print(max(s + q, s - p))
else:
	print(s)


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
s = 0
for i in range(n):
	if a[i] > 0:
		s += a[i]
	else:
		break
if s % 2:
	print(s)
else:
	mx = -100000
	for i in range(n):
		if a[i] < 0 and a[i] % 2:
			mx = max(a[i], mx)
	mn = 100000
	for i in range(n):
		if a[i] >= 0 and a[i] % 2:
			mn = min(a[i], mn)
	print(max(s + mx, s - mn))


n = int(input())
intr = list(map(int, input().split()))
sam = 0
t = 10 ** 18
for i in intr:
	if i > 0:
		sam += i
	if i % 2 != 0:
		t = min(t, abs(i))
if sam % 2 == 0:
	print(sam - t)
else:
	print(sam)


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]

def main():
	INF = 10 ** 10
	N = int(input())
	A = list(map(int, input().split()))
	dp_even = [0] * (N + 1)
	dp_odd = [0] * (N + 1)
	dp_even[0] = 0
	dp_odd[0] = -INF
	for i in range(1, N + 1):
		if A[i - 1] % 2 == 0:
			dp_even[i] = max(dp_even[i - 1], dp_even[i - 1] + A[i - 1])
			if dp_odd[i - 1] != -INF:
				dp_odd[i] = max(dp_odd[i - 1], dp_odd[i - 1] + A[i - 1])
			else:
				dp_odd[i] = -INF
		else:
			if dp_odd[i - 1] != -INF:
				dp_even[i] = max(dp_even[i - 1], dp_odd[i - 1] + A[i - 1])
			else:
				dp_even[i] = dp_even[i - 1]
			dp_odd[i] = max(dp_odd[i - 1], dp_even[i - 1] + A[i - 1])
	print(dp_odd[N])
main()


qtd = int(input())
numbers = list(map(int, input().split()))
min_positive = 9999
max_negative = -9999
summ = 0
for i in numbers:
	if i > 0:
		summ += i
		if i % 2 != 0 and i < min_positive:
			min_positive = i
	elif i % 2 != 0 and i > max_negative:
		max_negative = i
if summ % 2 == 0:
	print(summ - min(min_positive, -max_negative))
else:
	print(summ)


import sys
input()
arr = list(map(int, input().split()))
negs = sorted([x for x in arr if x < 0])
poss = sorted([x for x in arr if x > 0])
r = sum(poss)
if r % 2 == 1:
	print(r)
	sys.exit(0)
pos = [x for x in poss if x % 2 == 1]
pes = [x for x in poss if x % 2 == 0]
nos = [x for x in negs if x % 2 == 1]
nes = [x for x in negs if x % 2 == 0]
if not nos and (not nes):
	print(r - pos[0])
elif not pos and (not pes):
	print(0 + nos[-1])
elif not pos:
	print(r + nos[-1])
elif not nos:
	print(r - pos[0])
else:
	print(r - min(pos[0], -nos[-1]))


n = int(input())
a = [int(x) for x in input().split()]
s = 0
r = -10 ** 5
minodd = 10 ** 5
minminodd = -10 ** 5
for i in range(n):
	if a[i] > 0:
		s += a[i]
		if a[i] & 1 and a[i] < minodd:
			minodd = a[i]
	if a[i] < 0 and a[i] > minminodd and a[i] & 1:
		minminodd = a[i]
if s > 0 and s & 1:
	print(s)
elif minodd == 0:
	print(minminodd)
else:
	print(max(s - minodd, s + minminodd))


from math import inf
n = int(input())
lis = list(map(int, input().split()))
sum_ = 0
pos = []
neg = []
for val in lis:
	if val >= 0:
		pos.append(val)
		sum_ += val
	else:
		neg.append(val)
if sum_ % 2 == 1:
	print(sum_)
else:
	min_pos = inf
	for num in pos:
		if num < min_pos and num % 2 == 1:
			min_pos = num
	max_neg = -inf
	for num in neg:
		if num > max_neg and -num % 2 == 1:
			max_neg = num
	print(sum_ - min(min_pos, -max_neg))


def readInts():
	num = []
	for c in input().strip().split():
		num.append(int(c))
	return num

def solve(num):
	minOdd = 10000000
	maxNegOdd = -10000000
	sum = 0
	for x in num:
		if x > 0:
			sum = sum + x
			if x & 1:
				minOdd = min(minOdd, x)
		elif x & 1:
			maxNegOdd = max(maxNegOdd, x)
	if sum & 1:
		return sum
	if minOdd != 10000000 and maxNegOdd == -10000000:
		return sum - minOdd
	if maxNegOdd != -10000000 and minOdd == 10000000:
		return sum + maxNegOdd
	return max(sum - minOdd, sum + maxNegOdd)
n = int(input().strip())
num = readInts()
print(solve(num))


n = int(input())
a = list(map(int, input().split()))
odd_plus_min = 1000000000.0
odd_minus_max = -1000000000.0
sum = 0
for i in range(n):
	if a[i] > 0:
		sum += a[i]
	if abs(a[i]) % 2 != 0:
		if a[i] > 0:
			odd_plus_min = min(odd_plus_min, a[i])
		elif a[i] < 0:
			odd_minus_max = max(odd_minus_max, a[i])
res = 1000000000.0
if sum % 2 != 0:
	res = sum
else:
	if odd_plus_min < 1000000000.0:
		res = sum - odd_plus_min
	if odd_minus_max > -1000000000.0:
		if res < 1000000000.0:
			res = max(res, sum + odd_minus_max)
		else:
			res = sum + odd_minus_max
print(res)


n = int(input())
a = [int(s) for s in input().split()]
ap = [x for x in a if x > 0]
ap.sort()
bp = [x % 2 for x in ap]
ao = [x for x in a if x < 0]
ao.sort()
ao.reverse()
bo = [x % 2 for x in ao]
s = sum(ap)
cp = bp.count(1)
co = bo.count(1)
if cp % 2 == 1:
	print(s)
elif cp > 0:
	if co > 0:
		print(max(s + ao[bo.index(1)], s - ap[bp.index(1)]))
	else:
		print(s - ap[bp.index(1)])
else:
	print(s + ao[bo.index(1)])


n = int(input())
a = list(map(int, input().split()))
INF = 10 ** 18
dp = [[-INF] * 2 for i in range(n)]
if a[0] % 2 == 0:
	dp[0][0] = a[0]
else:
	dp[0][1] = a[0]
for i in range(1, n):
	if a[i] % 2:
		dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][0])
		dp[i][1] = max([a[i], dp[i - 1][0] + a[i], dp[i - 1][1]])
	else:
		dp[i][0] = max([a[i], dp[i - 1][0] + a[i], dp[i - 1][0]])
		dp[i][1] = max(dp[i - 1][1] + a[i], dp[i - 1][1])
print(dp[-1][1])


n = int(input())
a = list(map(int, input().split()))
(res, lst) = (0, [])
for (i, x) in enumerate(a):
	if x % 2 == 0:
		if x > 0:
			res += x
	else:
		lst.append(x)
lst.sort()
lst.reverse()
(res, k) = (res + lst[0], 1)
for (i, x) in enumerate(lst):
	if i == 0:
		continue
	if x < 0:
		if k == 0:
			if abs(x) < lst[i - 1]:
				res += x
				k = 1
			else:
				res -= lst[i - 1]
				k = 1
		break
	else:
		res += x
		if k == 1:
			k = 0
		else:
			k = 1
if k == 0:
	res -= lst[i]
print(res)


n = int(input())
a = list(map(int, input().split()))
s = 0
m = 10000000
for i in a:
	if i > 0:
		s += i
	if i & 1 == 1:
		m = min(m, abs(i))
if s & 1 != 1:
	s -= m
print(s)


x = int(input())
lista = list(map(int, input().split()))
ans = 0
impares = []
for i in range(x):
	if lista[i] > 0 and lista[i] % 2 == 0:
		ans += lista[i]
	elif lista[i] % 2 != 0:
		impares.append(lista[i])
som_imp = [0 for i in range(len(impares))]
impares.sort()
impares.reverse()
som_imp[0] = impares[0]
for i in range(1, len(impares)):
	som_imp[i] += impares[i] + som_imp[i - 1]
som_fin = []
k = -1000000000000
for i in range(0, len(som_imp), 2):
	k = max(som_imp[i], k)
ans += k
print(ans)


n = int(input())
a = list(map(int, input().split()))
s = []
s2 = []
for i in a:
	if i > 0:
		s.append(i)
	elif i < 0:
		s2.append(i)
s.sort()
s2 = sorted(s2)[::-1]
if sum(s) % 2:
	print(sum(s))
else:
	sm = sum(s)
	mn = 1e+18
	for i in s2:
		if i % 2:
			mn = min(abs(i), mn)
			break
	for i in s:
		if i % 2:
			mn = min(i, mn)
	print(sm - mn)


input()
a = [int(x) for x in input().split()]
oc = 0
ps = 0
pmo = 1000000.0
nmo = -1000000.0
for x in a:
	if x > 0:
		ps += x
	if x % 2 == 1 and x > 0 and (pmo > x):
		pmo = x
	if x % 2 == 1 and x > 0:
		oc += 1
	if x % 2 == 1 and x < 0 and (nmo < x):
		nmo = x
if oc % 2 == 1:
	print(ps)
else:
	print(max(ps - pmo, ps + nmo))


import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	a = list(map(int, input().split(' ')))
	pos = []
	neg = []
	for x in range(n):
		if a[x] >= 0:
			pos.append(a[x])
		else:
			neg.append(a[x])
	ans = sum(pos)
	if ans % 2 != 0:
		print(ans)
	else:
		realans = -int(1e+100)
		for x in pos:
			if (ans - x) % 2 != 0:
				realans = max(ans - x, realans)
		for x in neg:
			if (ans + x) % 2 != 0:
				realans = max(ans + x, realans)
		print(realans)
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')
main()


n = int(input())
seq = input().split(' ')
summ = 0
arr = []
minPosOdd = +999999999999999999999999999999999999
foundOdd = False
for i in seq:
	arr.append(int(i))
for i in range(n):
	if arr[i] > 0:
		summ = summ + arr[i]
	if arr[i] % 2 != 0:
		foundOdd = True
		if arr[i] > 0:
			minPosOdd = min(minPosOdd, arr[i])
		else:
			minPosOdd = min(minPosOdd, -1 * arr[i])
if summ % 2 == 0:
	summ = summ - minPosOdd
print(summ)


n = int(input())
arr = list(map(int, input().split()))
(pos, neg) = ([], [])
for i in arr:
	if i >= 0:
		pos += [i]
	else:
		neg += [i]
ans = sum(pos)
m_neg = -10 ** 10
s_odd = 10 ** 10
for i in neg:
	if i % 2 != 0:
		m_neg = max(m_neg, i)
for i in pos:
	if i % 2 != 0:
		s_odd = min(s_odd, i)
if ans % 2 != 0:
	print(ans)
else:
	(ans1, ans2) = (ans, ans)
	if m_neg != -10 ** 10:
		ans1 = ans + m_neg
	if s_odd != 10 ** 10:
		ans2 = ans - s_odd
	if ans1 % 2 != 0 and ans2 % 2 != 0:
		print(max(ans1, ans2))
	elif ans1 % 2 == 0 and ans2 % 2 != 0:
		print(ans2)
	elif ans1 % 2 != 0 and ans2 % 2 == 0:
		print(ans1)


n = int(input())
a = list(map(int, input().split()))
INF = 10 ** 10
even = 0
odd = []
one = -INF
for x in a:
	if x % 2:
		odd.append(x)
	elif x > 0:
		even += x
odd = list(reversed(sorted(odd)))
ans = even + odd[0]
i = 0
while i < len(odd):
	ans = max(even + odd[i], ans)
	if i < len(odd) - 1:
		if odd[i] + odd[i + 1] > 0:
			even += odd[i] + odd[i + 1]
	i += 2
print(ans)


n = int(input())
a = list(map(int, input().split()))
mini = 9999
sum = 0
for i in a:
	if i > 0:
		sum += i
	if i % 2 != 0:
		if abs(i) < mini:
			mini = abs(i)
if sum % 2 == 0:
	sum = sum - mini
print(sum)


n = int(input())
a = list(map(int, input().split()))
ans = 0
min_odd = float('-inf')
max_odd = float('inf')
for i in a:
	if i > 0:
		ans += i
	if i % 2 != 0:
		if i < 0:
			min_odd = max(min_odd, i)
		else:
			max_odd = min(max_odd, i)
if ans % 2 == 0:
	print(max(ans + min_odd, ans - max_odd))
else:
	print(ans)


import sys
n = int(input())
a = list(map(int, input().split()))
minf = -(2 * 10 ** 9)
dp = [[minf] * 2 for _ in range(n + 1)]
dp[0][0] = 0
for (i, x) in enumerate(a):
	dp[i + 1][0 + x & 1] = max(dp[i][0 + x & 1], dp[i + 1][0 + x & 1], dp[i][0] + x)
	dp[i + 1][1 + x & 1] = max(dp[i][1 + x & 1], dp[i + 1][1 + x & 1], dp[i][1] + x)
print(dp[-1][1])


n = int(input())
arr = list(map(int, input().split()))
i = 0
arr = sorted(arr, reverse=True)
Sum = 0
while i < n and arr[i] > 0:
	Sum += arr[i]
	i += 1
if Sum % 2 == 1:
	print(Sum)
else:
	k = i
	negSum = Sum
	while k < n and negSum % 2 == 0:
		if arr[k] % 2 == 1:
			negSum += arr[k]
		k += 1
	posSum = Sum
	j = i - 1
	while j >= 0 and posSum % 2 == 0:
		if arr[j] % 2 == 1:
			posSum -= arr[j]
		j -= 1
	if posSum % 2 == 0 and negSum % 2 == 1:
		print(negSum)
	elif posSum % 2 == 1 and negSum % 2 == 0:
		print(posSum)
	else:
		print(max(posSum, negSum))


n = int(input())
al = list(map(int, input().split()))
alpp = [a for a in al if a > 0 and a % 2 == 0]
s = sum(alpp)
alpi = [a for a in al if a > 0 and a % 2 == 1]
if len(alpi) % 2 == 0:
	if alpi:
		mini = min(alpi)
		s += sum(alpi)
		alni = [a for a in al if a < 0 and a % 2 == 1]
		if alni:
			maxi = max(alni)
			s += max(-mini, maxi)
		else:
			s -= mini
	else:
		s += sum(alpi)
		alni = [a for a in al if a < 0 and a % 2 == 1]
		maxi = max(alni)
		s += maxi
else:
	s += sum(alpi)
print(s)


from functools import reduce

def solve(arr, n):
	min_pos = max(arr)
	max_neg = min(arr)
	s = 0
	for x in arr:
		if x > 0:
			s += x
			if x & 1 and x < min_pos:
				min_pos = x
			continue
		if x % 2 and x > max_neg:
			max_neg = x
	if s & 1:
		return s
	if min_pos < 0 or min_pos % 2 == 0:
		return s + max_neg
	if max_neg > 0 or max_neg % 2 == 0:
		return s - min_pos
	return s - min(-max_neg, min_pos)
n = int(input())
arr = list(map(int, input().split()))
print(solve(arr, n))


n = int(input())
l_n = list(map(int, input().split()))
l_o = list()
s = 0
for n in l_n:
	if n % 2 == 0:
		if abs(n) == n:
			s += n
	else:
		l_o.append(n)
l_o.sort()
m_s = s
t_s = s
m_n_o = None
n_i = -1
for i in range(len(l_o)):
	if abs(l_o[i]) != l_o[i]:
		m_n_o = l_o[i]
		n_i = i
	else:
		break
if len(l_o) - n_i - 1 == 0:
	print(s + m_n_o)
elif (len(l_o) - n_i - 1) % 2 == 0:
	print(max(s + sum(l_o[n_i + 2:]), s + sum(l_o[n_i + 1:]) + (m_n_o if m_n_o else int(-10000000000.0))))
else:
	print(s + sum(l_o[n_i + 1:]))


n = int(input().strip())
ints = list(map(int, input().strip().split()))
negative = -20000
positive = 20000
ans = 0
for item in ints:
	if item > 0:
		ans += item
	if item % 2:
		if item < 0:
			negative = max(negative, item)
		else:
			positive = min(positive, item)
if ans % 2 == 0:
	ans -= min(abs(negative), positive)
print(ans)


n = int(input())
l = list(map(int, input().split()))
ans = 0
ma = -2000000000.0
mi = 2000000000.0
for i in range(n):
	if l[i] > 0:
		ans += l[i]
		if l[i] % 2 != 0:
			mi = min(mi, l[i])
	elif l[i] % 2 != 0:
		ma = max(ma, l[i])
if ans % 2 != 0:
	print(ans)
else:
	print(ans - min(mi, -ma))


n = int(input())
ns = map(int, input().split())
int_max = 1000000
summ = 0
m = int_max
for e in ns:
	if e > 0:
		summ += e
	if e % 2 != 0:
		m = min(m, abs(e))
if summ % 2 == 0:
	summ -= m
print(summ)


import sys
n = int(sys.stdin.readline())
l = list(map(int, sys.stdin.readline().split()))
b = []
c = []
d = []
for i in range(0, n):
	if l[i] % 2 == 0 and l[i] >= 0:
		b.append(l[i])
	elif l[i] % 2 != 0 and l[i] >= 0:
		c.append(l[i])
	elif l[i] % 2 != 0:
		d.append(l[i])
k = len(c)
sum1 = 0
if k == 0:
	sum1 += sum(b)
else:
	sum1 += sum(b) + sum(c)
	c.sort()
kk = len(d)
if kk != 0:
	d.sort()
if k % 2 != 0:
	print(sum1)
elif k == 0:
	sum1 += d[kk - 1]
	print(sum1)
elif kk == 0:
	sum1 -= c[0]
	print(sum1)
else:
	p = d[0]
	pp = c[0]
	sum2 = max(sum1 + d[kk - 1], sum1 - c[0])
	print(sum2)


n = int(input())
l = [int(i) for i in input().split()]
s = sum((i for i in l if i > 0))
if s % 2:
	print(s)
else:
	m = [abs(i) for i in l if i % 2 == 1]
	print(s - min(m))


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
i = 0
m1 = float('inf')
m2 = -float('inf')
while i < n and a[i] >= 0:
	if a[i] % 2 == 1:
		m1 = a[i]
	i += 1
s = sum(a[:i])
if s % 2 == 1:
	print(s)
else:
	while i < n and a[i] % 2 == 0:
		i += 1
	if i < n:
		m2 = a[i]
	print(max(s - m1, s + m2))


n = int(input())
lis = list(map(int, input().split()))
ans = 0
Min = 2 ** 63
for i in lis:
	if i > 0:
		ans += i
if ans % 2:
	print(ans)
else:
	ref = min([abs(i) for i in lis if i % 2])
	ans -= ref
	print(ans)


import math
n = int(input())
l = list(map(int, input().split()))
s = 0
for i in range(n):
	if l[i] > 0:
		s += l[i]
if s % 2 != 0:
	print(s)
else:
	m = math.inf
	d = math.inf * -1
	f = 0
	g = 0
	for i in range(n):
		if l[i] > 0 and l[i] < m and (l[i] % 2 != 0):
			m = l[i]
			f = 1
		if l[i] < 0 and l[i] > d and (l[i] % 2 != 0):
			d = l[i]
			g = 1
	e = math.inf * -1
	h = math.inf * -1
	if f == 1:
		e = s - m
	if g == 1:
		h = s + d
	print(e if e > h else h)


n = int(input())
inp = list(map(int, input().split()))
poseven = []
posodd = []
negeven = []
negodd = []
for item in inp:
	if item < 0 and item % 2 == 0:
		negeven.append(item)
	elif item < 0 and item % 2 == 1:
		negodd.append(item)
	elif item > 0 and item % 2 == 0:
		poseven.append(item)
	elif item > 0 and item % 2 == 1:
		posodd.append(item)
sumi = 0
sumi = sumi + sum(posodd) + sum(poseven)
if sumi % 2 == 0:
	if len(negodd) > 0:
		if len(posodd) > 0:
			sumi = max(sumi + max(negodd), sumi - min(posodd))
		else:
			sumi = sumi + max(negodd)
	else:
		sumi = sumi - min(posodd)
	print(sumi)
else:
	print(sumi)


input()
l = list(map(int, input().split()))
l.sort(reverse=True)
s = 0
beforeNeg = -10 ** 12
posEven = [x for x in l if x > 0 and x % 2 == 0]
posOdd = [x for x in l if x > 0 and x % 2 != 0]
posEven.sort()
posOdd.sort()
negOdd = [x for x in l if x < 0 and x % 2 != 0]
negOdd.sort(reverse=True)
if len(posOdd) % 2:
	print(sum(posOdd) + sum(posEven))
elif len(posOdd) > 0:
	if len(negOdd) > 0:
		if -negOdd[0] < posOdd[0]:
			print(sum(posOdd) + sum(posEven) + negOdd[0])
		else:
			print(sum(posOdd[1:]) + sum(posEven))
	else:
		print(sum(posOdd[1:]) + sum(posEven))
else:
	print(sum(posEven) + negOdd[0])


n = int(input())
l = list(map(int, input().split()))
c = [[], []]
for i in l:
	c[i % 2].append(i)
c[0].sort()
c[1].sort()
ans = 0
for i in c[0]:
	if i > 0:
		ans += i
ans += c[1][-1]
for i in range(len(c[1]) - 2, 0, -2):
	ans = max(ans, ans + c[1][i] + c[1][i - 1])
print(ans)