Inna is a great piano player and Dima is a modest guitar player. Dima has recently written a song and they want to play it together. Of course, Sereja wants to listen to the song very much. 

A song is a sequence of notes. Dima and Inna want to play each note at the same time. At that, they can play the i-th note at volume v (1 ≤ v ≤ a_{i}; v is an integer) both on the piano and the guitar. They should retain harmony, so the total volume with which the i-th note was played on the guitar and the piano must equal b_{i}. If Dima and Inna cannot play a note by the described rules, they skip it and Sereja's joy drops by 1. But if Inna and Dima play the i-th note at volumes x_{i} and y_{i} (x_{i} + y_{i} = b_{i}) correspondingly, Sereja's joy rises by x_{i}·y_{i}. 

Sereja has just returned home from the university and his current joy is 0. Help Dima and Inna play the song so as to maximize Sereja's total joy after listening to the whole song!


-----Input-----

The first line of the input contains integer n (1 ≤ n ≤ 10^5) — the number of notes in the song. The second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6). The third line contains n integers b_{i} (1 ≤ b_{i} ≤ 10^6).


-----Output-----

In a single line print an integer — the maximum possible joy Sereja feels after he listens to a song.


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

Output
4

Input
1
2
5

Output
-1



-----Note-----

In the first sample, Dima and Inna play the first two notes at volume 1 (1 + 1 = 2, the condition holds), they should play the last note at volumes 1 and 2. Sereja's total joy equals: 1·1 + 1·1 + 1·2 = 4.

In the second sample, there is no such pair (x, y), that 1 ≤ x, y ≤ 2, x + y = 5, so Dima and Inna skip a note. Sereja's total joy equals -1.

Source: codeforces | Difficulty: MEDIUM
Tags: Implementation


Solutions:
n = int(input())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))

def vol(x, y):
	if 2 * x >= y:
		a = y // 2
		return a * (y - a) or -1
	else:
		return -1
print(sum(map(vol, a, b)))


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
x = 0
for i in range(n):
	if 2 * a[i] >= b[i] and b[i] != 1:
		p = b[i] // 2
		q = b[i] - p
		x = x + p * q
	else:
		x = x - 1
print(x)


n = int(input())
a = [int(ai) for ai in input().split()]
b = [int(bi) for bi in input().split()]
joy = 0
for i in range(n):
	if 2 * a[i] >= b[i] and b[i] > 1:
		if b[i] % 2 == 0:
			joy += b[i] * b[i] / 4
		else:
			joy += (b[i] - 1) * (b[i] + 1) / 4
	else:
		joy -= 1
print(int(joy))


(n, a, b) = (input(), list(map(int, input().split())), list(map(int, input().split())))
print(sum((y // 2 * (y - y // 2) if y > 1 and 2 * x >= y else -1 for (x, y) in zip(a, b))))


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


n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

def check_even_odd(e):
	if e % 2 == 0:
		return 'Even'
	else:
		return 'Odd'
res = 0
i = 0
while i < n:
	add = 0
	prop = check_even_odd(B[i])
	if prop == 'Even':
		if A[i] >= B[i] // 2:
			add = (B[i] // 2) ** 2
		else:
			add = -1
	elif A[i] >= (B[i] + 1) // 2 and A[i] != 1 and (B[i] != 1):
		a = (B[i] + 1) // 2
		b = a - 1
		add = a * b
	else:
		add = -1
	res += add
	i += 1
print(res)


input()
anotes = input().split(' ')
bnotes = input().split(' ')
joy = 0
for i in range(0, len(anotes)):
	if int(bnotes[i]) > 1 and int(anotes[i]) * 2 >= int(bnotes[i]):
		joy += int(bnotes[i]) // 2 * (int(bnotes[i]) // 2 + int(bnotes[i]) % 2)
	else:
		joy -= 1
print(joy)


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


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	joy = 0
	for i in range(n):
		temp2 = (b[i] + 1) // 2
		if a[i] >= temp2 and b[i] != 1:
			temp1 = b[i] // 2
			joy += temp1 * temp2
		elif a[i] * 2 < b[i] or b[i] == 1:
			joy -= 1
		else:
			temp1 = a[i]
			temp2 = a[i]
			joy += temp1 * temp2
	print(joy)
main()


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


import math
import cmath
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for x in range(n):
	if b[x] > 2 * a[x] or b[x] - b[x] // 2 == 0 or b[x] // 2 == 0:
		ans -= 1
	else:
		ans += b[x] // 2 * (b[x] - b[x] // 2)
print(ans)


import math
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
result = 0
for i in range(n):
	if b[i] < 2 or b[i] > 2 * a[i]:
		result -= 1
	else:
		result += math.floor(b[i] / 2) * math.ceil(b[i] / 2)
print(result)


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


def return_happiness(a, b):
	total_happiness = 0
	for (a_i, b_i) in zip(a, b):
		if 2 * a_i < b_i or b_i == 1:
			total_happiness -= 1
		else:
			total_happiness += b_i // 2 * (b_i // 2 + b_i % 2)
	return total_happiness
n = input()
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
print(return_happiness(a, b))


n = int(input())
a = input().split()
a = list(map(lambda x: int(x) if x.isdigit() else 0, a))
b = input().split()
b = list(map(lambda x: int(x) if x.isdigit() else 0, b))
sum = 0
while len(a) > 0:
	if b[len(a) - 1] == 1:
		sum -= 1
	elif a[len(a) - 1] == 1:
		if b[len(a) - 1] == 2:
			sum += 1
		else:
			sum -= 1
	else:
		c = int(b[len(a) - 1] / 2)
		while c > a[len(a) - 1]:
			c -= 1
		if b[len(a) - 1] - c > a[len(a) - 1]:
			sum -= 1
		else:
			sum = sum + c * (b[len(a) - 1] - c)
	d = len(a)
	del a[d - 1]
	del b[d - 1]
print(sum)


import math

class CodeforcesTask390BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.a = []
		self.b = []

	def read_input(self):
		self.n = int(input())
		self.a = [int(x) for x in input().split(' ')]
		self.b = [int(x) for x in input().split(' ')]

	def process_task(self):
		joy = 0
		for note in range(self.n):
			if self.a[note] * 2 < self.b[note] or self.b[note] == 1:
				joy -= 1
			elif not self.b[note] % 2:
				joy += (self.b[note] // 2) ** 2
			else:
				joy += self.b[note] // 2 * (self.b[note] // 2 + 1)
		self.result = str(joy)

	def get_result(self):
		return self.result
Solution = CodeforcesTask390BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


input()
print(sum((-1 if b > 2 * a or b == 1 else b // 2 * ((b + 1) // 2) for (a, b) in zip(map(int, input().split()), map(int, input().split())))))


from math import *
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
for i in range(n):
	if 2 * a[i] < b[i] or b[i] == 1:
		res -= 1
	else:
		res += b[i] // 2 * (b[i] - b[i] // 2)
print(res)


num = int(input())
arr_a = list(map(int, input().split()))
arr_b = list(map(int, input().split()))
joy = 0
for i in range(num):
	if arr_b[i] == 1:
		joy -= 1
		continue
	if arr_a[i] * 2 >= arr_b[i]:
		temp = arr_b[i] // 2
		joy = joy + temp * (arr_b[i] - temp)
	else:
		joy -= 1
print(joy)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
glad = [b[i] // 2 * (b[i] - b[i] // 2) if b[i] != 1 and b[i] <= 2 * a[i] else -1 for i in range(len(b))]
print(sum(glad))


import math
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(res, v1, v2) = (0, 0, 0)
for i in range(n):
	if b[i] > 1 and b[i] <= 2 * a[i]:
		v1 = math.ceil(b[i] / 2)
		v2 = b[i] - v1
		res += v1 * v2
	else:
		res -= 1
print(res)


def main():
	n = int(input())
	a = list(map(float, input().split(' ')))
	b = list(map(float, input().split(' ')))
	iterr = list(zip(a, b))
	happiness = 0
	for (x, y) in iterr:
		if x < y / 2 or y == 1:
			happiness -= 1
		elif x == y / 2:
			happiness += x * x
		elif x > y / 2:
			if y % 2 == 0:
				x = y // 2
				happiness += x * x
			else:
				x = (y + 1) // 2
				happiness += x * (y - x)
	print(int(happiness))
main()


from math import *
n = int(input())
a = input().split()
a = list(map(lambda x: int(x) if x.isdigit() else 0, a))
b = input().split()
b = list(map(lambda x: int(x) if x.isdigit() else 0, b))
sum = 0
for i in range(n):
	if b[i] == 1:
		sum -= 1
	elif a[i] == 1:
		if b[i] == 2:
			sum += 1
		else:
			sum -= 1
	else:
		c = int(b[i] / 2)
		while c > a[i]:
			c -= 1
		if b[i] - c > a[i]:
			sum -= 1
		else:
			sum = sum + c * (b[i] - c)
print(sum)


def great_sum_finder(num, rang):
	if abs(num - rang) > rang or num == 1:
		return -1
	if rang == 1:
		return 1
	if num < rang:
		return great_sum_finder(num, num - 1)
	return num // 2 * (num - num // 2)
n = int(input())
a = input().split()
b = input().split()
a = list(map(int, a))
b = list(map(int, b))
joy = 0
for i in range(n):
	joy += great_sum_finder(b[i], a[i])
print(joy)


import math
n = int(input())
aList = list(map(int, input().split()))
bList = list(map(int, input().split()))
joy = 0
for i in range(n):
	if bList[i] == 1:
		joy = joy - 1
	else:
		if bList[i] % 2 == 0:
			b1 = bList[i] / 2
			b2 = bList[i] / 2
		else:
			b1 = math.floor(bList[i] / 2)
			b2 = math.ceil(bList[i] / 2)
		if b2 <= aList[i]:
			joy = joy + b1 * b2
		else:
			joy = joy - 1
print(int(joy))


(N, A, B, Joy) = (int(input()), list(map(int, input().split())), list(map(int, input().split())), 0)
for i in range(N):
	if A[i] * 2 < B[i] or B[i] == 1:
		Joy -= 1
	else:
		Joy += (B[i] // 2) ** 2 if B[i] % 2 == 0 else B[i] // 2 * (B[i] // 2 + 1)
print(Joy)


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


q = lambda : map(int, input().split())
(n,) = q()
a = list(q())
b = list(q())
c = 0
for (i, j) in zip(a, b):
	if j == 1:
		c -= 1
	elif i * 2 >= j:
		c += j // 2 * (j - j // 2)
	else:
		c -= 1
print(c)


import math
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = int(0)
for i in range(n):
	if b[i] == 1:
		c -= 1
	elif a[i] * 2 < b[i]:
		c -= 1
	elif b[i] % 2 == 0:
		c += int((b[i] / 2) ** 2)
	else:
		c += int(int(math.ceil(b[i] / 2)) * int(math.floor(b[i] / 2)))
print(c)