Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will make a pile of snow of volume V_{i} and put it in her garden.

Each day, every pile will shrink a little due to melting. More precisely, when the temperature on a given day is T_{i}, each pile will reduce its volume by T_{i}. If this would reduce the volume of a pile to or below zero, it disappears forever. All snow piles are independent of each other. 

Note that the pile made on day i already loses part of its volume on the same day. In an extreme case, this may mean that there are no piles left at the end of a particular day.

You are given the initial pile sizes and the temperature on each day. Determine the total volume of snow melted on each day. 


-----Input-----

The first line contains a single integer N (1 ≤ N ≤ 10^5) — the number of days. 

The second line contains N integers V_1, V_2, ..., V_{N} (0 ≤ V_{i} ≤ 10^9), where V_{i} is the initial size of a snow pile made on the day i.

The third line contains N integers T_1, T_2, ..., T_{N} (0 ≤ T_{i} ≤ 10^9), where T_{i} is the temperature on the day i.


-----Output-----

Output a single line with N integers, where the i-th integer represents the total volume of snow melted on day i.


-----Examples-----
Input
3
10 10 5
5 7 2

Output
5 12 4

Input
5
30 25 20 15 10
9 10 12 4 13

Output
9 20 35 11 25



-----Note-----

In the first sample, Bob first makes a snow pile of volume 10, which melts to the size of 5 on the same day. On the second day, he makes another pile of size 10. Since it is a bit warmer than the day before, the first pile disappears completely while the second pile shrinks to 3. At the end of the second day, he has only a single pile of size 3. On the third day he makes a smaller pile than usual, but as the temperature dropped too, both piles survive till the end of the day.

Difficulty: MEDIUM_HARD
Tags: Sorting

Data structures
Skill types: Sorting

Data structures

Starter code:

Solutions:
from sys import stdin, stdout
from heapq import *
n = int(input())
v = list(map(int, input().split()))
t = list(map(int, input().split()))
heap = []
eps = 0
for i in range(n):
	ans = 0
	heappush(heap, eps + v[i])
	while heap:
		if heap[0] >= eps + t[i]:
			break
		ans += heap[0] - eps
		heappop(heap)
	ans += len(heap) * t[i]
	eps += t[i]
	print(ans, end=' ')


n = int(input())
import heapq as hq
heap = []
temp = 0
ans = [-1 for _ in range(n)]
volumes = [int(x) for x in input().split()]
temps = [int(x) for x in input().split()]
for i in range(n):
	prevtemp = temp
	temp += temps[i]
	hq.heappush(heap, volumes[i] + prevtemp)
	curr = 0
	while len(heap) and heap[0] <= temp:
		m = hq.heappop(heap)
		curr += m - prevtemp
	curr += len(heap) * temps[i]
	ans[i] = curr
print(' '.join([str(x) for x in ans]))


from sys import stdin, stdout
from heapq import *
n = int(input())
v = list(map(int, input().split()))
t = list(map(int, input().split()))
heap = []
counter = 0
for i in range(n):
	res = 0
	item = counter + v[i]
	heappush(heap, item)
	while heap:
		if heap[0] >= counter + t[i]:
			break
		res += heap[0] - counter
		heappop(heap)
	res += len(heap) * t[i]
	counter += t[i]
	print(str(res) + ' ')


from heapq import *
n = int(input())
l = list(map(int, input().split()))
l1 = list(map(int, input().split()))
L = []
heapify(L)
l2 = l1[:]
qw = []
for i in range(1, n):
	l2[i] += l2[i - 1]
for i in range(n):
	v = l[i] + l2[i] - l1[i]
	heappush(L, v)
	mi = heappop(L)
	count = 0
	while mi <= l2[i]:
		count += mi - l2[i] + l1[i]
		if not L:
			break
		mi = heappop(L)
	else:
		heappush(L, mi)
	ost = count + len(L) * l1[i]
	qw.append(ost)
print(*qw)


from heapq import *
n = int(input())
v = list(map(int, input().split()))
t = list(map(int, input().split()))
s = 0
h = []
ans = []
for i in range(n):
	heappush(h, v[i] + s)
	sm = 0
	while h and h[0] <= s + t[i]:
		sm += heappop(h) - s
	ans.append(sm + len(h) * t[i])
	s += t[i]
print(*ans)


import heapq
heap = []
n = int(input())
V = list(map(int, input().split()))
T = list(map(int, input().split()))
tmp = 0
for i in range(n):
	ans = 0
	heapq.heappush(heap, tmp + V[i])
	while len(heap) and heap[0] <= tmp + T[i]:
		ans += heapq.heappop(heap) - tmp
	tmp += T[i]
	ans += T[i] * len(heap)
	print(ans, end=' ')


import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a = [0] + a
	b = [0] + b
	ans = [0] * (n + 1)
	p = [0] * (n + 1)
	ans = [0] * (n + 1)
	ct = [0] * (n + 1)
	for i in range(1, n + 1):
		p[i] = p[i - 1] + b[i]
	from bisect import bisect_right as ub
	for i in range(1, n + 1):
		j = ub(p, p[i - 1] + a[i])
		ct[i] += 1
		if j == n + 1:
			continue
		ct[j] -= 1
		ans[j] += p[i - 1] + a[i] - p[j - 1]
	for i in range(1, n + 1):
		ct[i] += ct[i - 1]
	for i in range(1, n + 1):
		ans[i] += ct[i] * b[i]
	print(*ans[1:])
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())
vs = [int(x) for x in input().split()]
ts = [int(x) for x in input().split()]
from heapq import *
q = []
heapify(q)
sts = ts[:]
for i in range(1, n):
	sts[i] += sts[i - 1]
res = []
for i in range(n):
	v = vs[i]
	t = ts[i]
	v += sts[i] - ts[i]
	heappush(q, v)
	minv = heappop(q)
	count = 0
	while minv <= sts[i]:
		count += minv - sts[i] + ts[i]
		if not q:
			break
		minv = heappop(q)
	else:
		heappush(q, minv)
	res.append(count + len(q) * t)
print(' '.join(map(str, res)))


def bin_search(pref, diff, s, val):
	e = len(pref) - 1
	index = -1
	while s <= e:
		mid = s + e >> 1
		if pref[mid] - diff <= val:
			index = mid
			s = mid + 1
		else:
			e = mid - 1
	return index
n = int(input())
a = list(map(int, input().split()))
t = list(map(int, input().split()))
pref = [0 for i in range(len(t))]
pref[0] = t[0]
for i in range(1, len(t)):
	pref[i] = t[i] + pref[i - 1]
freq = [0 for i in range(len(t))]
ans = [0 for i in range(len(t))]
diff = 0
for i in range(0, n):
	index = bin_search(pref, diff, i, a[i])
	if index == -1:
		ans[i] += a[i]
	else:
		freq[i] += 1
		if index + 1 < n:
			freq[index + 1] -= 1
			ans[index + 1] += a[i] - pref[index] + diff
	diff += t[i]
for i in range(1, n):
	freq[i] = freq[i] + freq[i - 1]
for i in range(0, n):
	print(freq[i] * t[i] + ans[i], end=' ')
print()


from sys import stdin, stdout
n = int(input())
v = [*map(int, stdin.readline().split())]
t = [*map(int, stdin.readline().split())]
sumt = [0] * n
for i in range(n):
	sumt[i] = (0 if i == 0 else sumt[i - 1]) + t[i]

def psum(i, j):
	if i > j:
		return 0
	return sumt[j] - (0 if i == 0 else sumt[i - 1])
a = [0] * (n + 1)
b = [0] * (n + 1)
for i in range(n):
	(l, r) = (i, n - 1)
	k = n
	while l <= r:
		mid = (l + r) // 2
		if psum(i, mid) >= v[i]:
			k = mid
			r = mid - 1
		else:
			l = mid + 1
	a[i] += 1
	a[k] -= 1
	b[k] += v[i] - psum(i, k - 1)
for i in range(1, n):
	a[i] += a[i - 1]
ans = [0] * n
for i in range(n):
	ans[i] = t[i] * a[i] + b[i]
print(*ans)


from sys import stdin
input = stdin.readline
import heapq

def f(v, t):
	ans = 0
	r = 0
	q = []
	heapq.heapify(q)
	for i in range(len(v)):
		ans = 0
		heapq.heappush(q, v[i] + r)
		while q and q[0] < t[i] + r:
			ans += heapq.heappop(q) - r
		ans += len(q) * t[i]
		print(ans, end=' ')
		r += t[i]
n = input()
l = list(map(int, input().strip().split()))
d = list(map(int, input().strip().split()))
f(l, d)


import sys, os, io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
import math

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

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

def solve():
	n = ii()
	v = li()
	t = li()
	p = []
	for i in range(n):
		if i == 0:
			p.append(t[i])
		else:
			p.append(t[i] + p[-1])
	halfvolumemeltedDay = [0] * n
	ans = [0] * n
	suf = [0] * n
	for i in range(n):
		prev = 0
		if i > 0:
			prev = p[i - 1]
		ans = bisect_left(p, v[i] + prev, i, n - 1)
		if p[ans] <= v[i] + prev:
			ans += 1
		if ans < n:
			halfvolumemeltedDay[ans] += v[i] - ((0 if ans == 0 else p[ans - 1]) - prev)
		if i > 0:
			suf[i - 1] -= 1
		if ans > 0:
			suf[ans - 1] += 1
	for i in range(n - 2, -1, -1):
		suf[i] += suf[i + 1]
	ans = [0] * n
	for i in range(n):
		ans[i] += halfvolumemeltedDay[i] + suf[i] * t[i]
	print(*ans)
t = 1
for _ in range(t):
	solve()


from itertools import accumulate
import bisect
n = int(input())
v = list(map(int, input().split()))
t = list(map(int, input().split()))
ns = [0] * n
lo = [0] * n
tt = list(accumulate(t))
for i in range(n):
	dd = v[i]
	a = 0
	if i != 0:
		dd += tt[i - 1]
		a = tt[i - 1]
	ns[i] += 1
	k = bisect.bisect_right(tt, dd)
	if k < n:
		ns[k] -= 1
		lo[k] += +v[i] + a
		if k != 0:
			lo[k] -= tt[k - 1]
ns = list(accumulate(ns))
for i in range(n):
	lo[i] += t[i] * ns[i]
print(' '.join(list(map(str, lo))))


import sys, os, io
from sys import stdin
from bisect import bisect_left, bisect_right

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

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

def solve():
	n = ii()
	p = []
	v = li()
	t = li()
	for i in range(n):
		if i == 0:
			p.append(t[i])
		else:
			p.append(t[i] + p[-1])
	halfvolumemeltedDay = [0] * n
	suf = [0] * n
	for i in range(n):
		prev = 0
		if i > 0:
			prev = p[i - 1]
		ans = bisect_left(p, v[i] + prev, i, n - 1)
		if p[ans] <= v[i] + prev:
			ans += 1
		if ans < n:
			halfvolumemeltedDay[ans] += v[i] - ((0 if ans == 0 else p[ans - 1]) - prev)
		if i > 0:
			suf[i - 1] -= 1
		if ans > 0:
			suf[ans - 1] += 1
	for i in range(n - 2, -1, -1):
		suf[i] += suf[i + 1]
	ans = [0] * n
	for i in range(n):
		ans[i] += halfvolumemeltedDay[i] + suf[i] * t[i]
	print(*ans)
for _ in range(1):
	solve()


import sys
input = sys.stdin.readline

def binary_search(org, arr, l, r, n, L, value):
	mid = (l + r) // 2
	if mid > 0 and arr[mid] - value >= org and (arr[mid - 1] - value < org):
		return mid
	elif mid == 0 and arr[mid] - value >= org:
		return mid
	elif mid == L and arr[mid] - value >= org:
		return mid
	elif mid == n:
		return mid
	elif mid > 0 and arr[mid] - value > org and (arr[mid - 1] - value >= org):
		return binary_search(org, arr, l, mid, n, L, value)
	elif arr[mid] - value < org:
		return binary_search(org, arr, mid + 1, r, n, L, value)
	return mid
n = int(input())
l = list(map(int, input().split()))
u = list(map(int, input().split()))
extra = [0] * n
pre = [0] * n
t = [0] * n
t[0] = u[0]
for i in range(1, n):
	t[i] += t[i - 1] + u[i]
for i in range(n):
	if i > 0:
		v = t[i - 1]
	else:
		v = 0
	index = binary_search(l[i], t, i, n - 1, n - 1, i, v)
	if index > 0 and index != i:
		value = t[index] - t[index - 1]
		remain = l[i] - (t[index - 1] - v)
	elif index > 0 and index == i:
		value = t[index] - t[index - 1]
		remain = l[i]
	else:
		value = t[index]
		remain = l[i]
	if value >= remain:
		extra[index] += remain
	elif remain > value:
		extra[index] += value
	if i > 0 and index > 0:
		pre[i - 1] -= 1
		pre[index - 1] += 1
	elif i == 0 and index > 0:
		pre[index - 1] += 1
	elif i == 0 and index == 0:
		continue
for i in range(n - 2, -1, -1):
	pre[i] += pre[i + 1]
r = [0] * n
for i in range(n):
	r[i] = u[i] * pre[i] + extra[i]
for i in r:
	print(i, end=' ')


import os
import sys
from io import BytesIO, IOBase
mod = 10 ** 9 + 7
from bisect import bisect

def main():
	n = int(input())
	v = list(map(int, input().split()))
	t = list(map(int, input().split()))
	z = 0
	temp = [0]
	for item in t:
		z += item
		temp.append(z)
	d = dict()
	dff = dict()
	for (i, item) in enumerate(v):
		z = bisect(temp, item + temp[i])
		z -= 1
		if z not in d:
			d[z] = []
			dff[z] = []
		d[z].append(item)
		dff[z].append(item - (temp[z] - temp[i]))
	z = 0
	ans = []
	for i in range(n):
		x = 0
		if i in d:
			z += 1 - len(d[i])
			for item in dff[i]:
				x += item
		else:
			z += 1
		x += z * t[i]
		ans.append(x)
	print(*ans)

def nouse0():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse1():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse2():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
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 nouse3():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse4():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse5():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
main()


import sys
import math
import collections
inp = lambda : int(input())
strng = lambda : input().strip()
strl = lambda : list(input().strip())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
mod = 10 ** 9 + 7
input = sys.stdin.readline

def bs(l, h, v):
	if l <= h:
		m = (l + h) // 2
		if pret[m] < v:
			if m == h:
				return m
			else:
				return bs(m + 1, h, v)
		else:
			if m - 1 >= l and pret[m - 1] >= v:
				return bs(l, m - 1, v)
			return m
	return -1
n = inp()
v = seq()
t = seq()
pret = [0] * n
pret[0] = t[0]
for i in range(1, n):
	pret[i] = pret[i - 1] + t[i]
freq = [0] * n
extra = [0] * n
for i in range(n):
	temp = v[i]
	if i > 0:
		temp += pret[i - 1]
	val = bs(i, n - 1, temp)
	if val == i:
		if temp >= pret[i]:
			freq[i] += 1
			if i > 0:
				freq[i - 1] -= 1
		elif temp < pret[i]:
			diff = pret[i] - temp
			extra[i] += t[i] - diff
	elif temp >= pret[val]:
		freq[val] += 1
		if i > 0:
			freq[i - 1] -= 1
	elif temp < pret[val]:
		diff = pret[val] - temp
		extra[val] += t[val] - diff
		freq[val - 1] += 1
		if i > 0:
			freq[i - 1] -= 1
ans = [''] * n
curr = 0
for i in range(n - 1, -1, -1):
	temp = freq[i]
	freq[i] += curr
	curr += temp
for i in range(n):
	temp = freq[i] * t[i] + extra[i]
	temp = str(temp)
	ans[i] = temp
print(' '.join(ans))


import configparser
import math
import sys
input = sys.stdin.readline

def get(l, r, cumsum):
	res = cumsum[r]
	if l >= 1:
		res -= cumsum[l - 1]
	return res

def can(l, r, cumsum, am):
	return am >= get(l, r, cumsum)

def main():
	n = int(input())
	v = [int(x) for x in input().split(' ')]
	t = [int(x) for x in input().split(' ')]
	cumsum = [0 for i in range(n)]
	cumsum[0] = t[0]
	for i in range(1, n):
		cumsum[i] = t[i] + cumsum[i - 1]
	ans = [0 for i in range(n)]
	alive = [[] for i in range(n)]
	for i in range(n):
		pos = i - 1
		for j in range(25, -1, -1):
			jump = 2 ** j
			if pos + jump < n and can(i, pos + jump, cumsum, v[i]):
				pos += jump
		if pos == i - 1:
			alive[i].append(v[i])
		else:
			ans[i] += 1
			if pos + 1 < n:
				ans[pos + 1] -= 1
			if pos != n - 1 and v[i] > get(i, pos, cumsum):
				alive[pos + 1].append(v[i] - get(i, pos, cumsum))
	for i in range(1, n):
		ans[i] += ans[i - 1]
	res = [0 for i in range(n)]
	for i in range(n):
		res[i] = ans[i] * t[i]
		for j in alive[i]:
			res[i] += j
	for i in res:
		print(i, end=' ')
main()


import heapq
n = int(input())
V = list(map(int, input().split()))
T = list(map(int, input().split()))
a = []
ans = []
tmp = 0
for i in range(0, n):
	heapq.heappush(a, tmp + V[i])
	tmpAns = 0
	while len(a) and a[0] <= tmp + T[i]:
		tmpAns += heapq.heappop(a) - tmp
	tmpAns += len(a) * T[i]
	ans.append(tmpAns)
	tmp += T[i]
print(' '.join(map(str, ans)))


import os
import sys
from io import BytesIO, IOBase
import heapq

def main():
	n = int(input())
	v = list(map(int, input().split()))
	t = list(map(int, input().split()))
	heap = []
	summ = 0
	for i in range(n):
		cur = 0
		heapq.heappush(heap, summ + v[i])
		summ += t[i]
		while heap:
			item = heap[0]
			if summ < item:
				cur += len(heap) * t[i]
				break
			else:
				heapq.heappop(heap)
				cur += item - (summ - t[i])
		print(cur, end=' ')
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()


import os
import sys
from io import BytesIO, IOBase
from bisect import *

def main():
	n = int(input())
	v = list(map(int, input().split()))
	t = list(map(int, input().split()))
	p = [0] * (n + 1)
	for (i, val) in enumerate(t):
		p[i + 1] += p[i] + val
	ans = [0] * n
	b = [0] * n
	for i in range(n):
		z = bisect_left(p, p[i] + v[i])
		z -= z != 0
		z -= z == n
		ans[z] += min(v[i] - (p[z] - p[i]), t[z])
		b[z] -= 1
		b[i] += 1
	for i in range(1, n):
		b[i] += b[i - 1]
	for i in range(n):
		ans[i] += t[i] * b[i]
	print(*ans)
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()


from collections import Counter
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 dice():
	dp = [0] * (n + 1)
	dp[1] = 1
	dp[0] = 1
	for i in range(2, n + 1):
		for j in range(1, 7):
			if i - j >= 0:
				dp[i] = (dp[i] + dp[i - j]) % (10 ** 9 + 7)
			else:
				break
import sys

def shut():
	import os
	shutdown = input()
	if shutdown == 'no':
		exit()
	else:
		os.system('shutdown /s /t 1')

def cost(l, r, ch, s):
	var = 0
	for i in range(l, r):
		if s[i] != ch:
			var += 1
	return var

def fxn(l, r, ch, s):
	if l + 1 == r:
		if s[l] == ch:
			return 0
		return 1
	mid = (l + r) // 2
	return min(cost(l, mid, ch, s) + fxn(mid, r, chr(ord(ch) + 1), s), fxn(l, mid, chr(ord(ch) + 1), s) + cost(mid, r, ch, s))
import heapq
n = int(input())
v = list(map(int, input().split()))
t = list(map(int, input().split()))
heap = []
sum = 0
for i in range(n):
	ans = 0
	heapq.heappush(heap, v[i] + sum)
	while len(heap) and heap[0] < sum + t[i]:
		ans += heap[0] - sum
		heapq.heappop(heap)
	ans += len(heap) * t[i]
	sum += t[i]
	print(ans, end=' ')


from itertools import accumulate
import sys

def binary_search(l, r, x):
	m = (l + r) // 2
	if l >= r:
		return m + 1
	if T[m] <= x:
		return binary_search(m + 1, r, x)
	return binary_search(l, m, x)
n = int(sys.stdin.readline().strip())
S = list(map(int, sys.stdin.readline().strip().split(' ')))
Tinit = list(map(int, sys.stdin.readline().strip().split(' ')))
T = list(accumulate(Tinit))
T.append(T[-1])
res = [0 for i in range(n + 1)]
add = [0 for i in range(n + 1)]
for i in range(n):
	k = binary_search(0, n - 1, S[i] + T[i - 1] if i > 0 else S[i])
	res[i] += 1
	res[k] -= 1
	if S[i] < (T[k] - T[i - 1] if i > 0 else T[k - 1]):
		add[k - 1] += S[i] - (T[k - 1] - T[i - 1] if i > 0 else T[k - 1])
res = list(accumulate(res))
for i in range(n):
	sys.stdout.write(str(res[i] * Tinit[i] + add[i]))
	if i != n - 1:
		sys.stdout.write(' ')
	else:
		sys.stdout.write('\n')


import heapq
n = int(input())
v = list(map(int, input().split()))
t = list(map(int, input().split()))
q = []
melted = 0
for (snow, temp) in zip(v, t):
	heapq.heappush(q, snow + melted)
	answer = 0
	while q and q[0] <= melted + temp:
		answer += q[0] - melted
		heapq.heappop(q)
	answer += temp * len(q)
	print(answer, end=' ')
	melted += temp


from bisect import *
n = int(input())
h = list(map(int, input().split()))
t = list(map(int, input().split()))
dp = [1 for i in range(n + 1)]
reminder = [0 for i in range(n + 1)]
pre_sum = [0 for i in range(n)]
pre_sum[0] = t[0]
for i in range(1, n):
	pre_sum[i] = pre_sum[i - 1] + t[i]
pre = 0
for i in range(n):
	cur = pre + h[i]
	pre = pre_sum[i]
	index = bisect(pre_sum, cur)
	dp[index] -= 1
	if index == 0:
		reminder[index] += cur
	else:
		reminder[index] += cur - pre_sum[index - 1]
for i in range(1, n):
	dp[i] = dp[i - 1] + dp[i]
for i in range(n):
	temp = dp[i] * t[i] + reminder[i]
	print(temp, end=' ')
print()


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
N = int(input())
V = alele()
T = alele()
B = [0] + list(accumulate(T))
Ans1 = [0] * (N + 2)
Ans2 = [0] * (N + 2)
for i in range(N):
	x = V[i]
	if T[i] < V[i]:
		a = bisect.bisect_left(B, x + B[i])
		Ans2[i] += 1
		Ans2[a - 1] -= 1
		if T[i] < V[i]:
			z = B[a - 1] - B[i]
			zz = V[i] - z
			Ans1[a - 1] += zz
	else:
		Ans1[i] += V[i]
C = list(accumulate(Ans2))
for i in range(N):
	print(C[i] * T[i] + Ans1[i], end=' ')


n = int(input())
vs = [int(x) for x in input().split()]
ts = [int(x) for x in input().split()]
sumt = 0
for (i, t) in enumerate(ts):
	vs[i] += sumt
	sumt += t
vs.sort()
(tl, tr) = (0, 0)
(il, ir) = (0, 0)
for (ind, t) in enumerate(ts):
	tl = tr
	tr += t
	while ir < n and vs[ir] <= tr:
		ir += 1
	cur_sum = 0
	while il < ir:
		cur_sum += vs[il] - tl
		il += 1
	cur_sum += t * (n - ir - (n - ind - 1))
	print(cur_sum, end=' ')


import sys
input = sys.stdin.readline

def judge(i, x):
	return V[i] - (T_acc[x + 1] - T_acc[i]) > 0

def binary_search(i):
	(l, r) = (0, N)
	while l <= r:
		mid = (l + r) // 2
		if judge(i, mid):
			l = mid + 1
		else:
			r = mid - 1
	return r
N = int(input())
V = list(map(int, input().split()))
T = list(map(int, input().split()))
T.append(10 ** 18)
T_acc = [0]
for Ti in T:
	T_acc.append(T_acc[-1] + Ti)
last = [0] * (N + 1)
imos = [0] * (N + 1)
for i in range(N):
	mark = binary_search(i)
	last[mark + 1] += V[i] - (T_acc[mark + 1] - T_acc[i])
	imos[i] += 1
	imos[mark + 1] -= 1
for i in range(N):
	imos[i + 1] += imos[i]
for i in range(N):
	ans = imos[i] * T[i] + last[i]
	if i < N - 1:
		print(ans, end=' ')
	else:
		print(ans)


from itertools import accumulate
from bisect import bisect
n = int(input())
vs = list(map(int, input().split()))
ts = list(map(int, input().split()))
fully_melt = [0] * n
result = [0] * n
dprint = lambda *args: None
ts_accum = list(accumulate(ts))
dprint('ts_accum', ts_accum)
for (i, v) in enumerate(vs):
	offset = ts_accum[i - 1] if i > 0 else 0
	p = bisect(ts_accum, v + offset, lo=i)
	dprint('i = ', i, ', p =', p, ', offset = ', offset)
	if p < n:
		fully_melt[p] += 1
		result[p] -= ts_accum[p] - v - offset
dprint('fully_melt', fully_melt)
dprint('result', result)
multiplier = 1
for (i, t) in enumerate(ts):
	dprint('i =', i, ', mult =', multiplier)
	result[i] += t * multiplier
	multiplier += 1 - fully_melt[i]
print(' '.join((str(r) for r in result)))


import heapq
n = int(input())
v = list(map(int, input().split()))
t = list(map(int, input().split()))
d = []
s = 0
for i in range(n):
	ans = 0
	heapq.heappush(d, v[i] + s)
	while d and d[0] <= s + t[i]:
		ans += d[0] - s
		heapq.heappop(d)
	s += t[i]
	ans += len(d) * t[i]
	print(ans, end=' ')


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')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

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

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

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
from bisect import bisect_right

def main():
	n = N()
	arrv = RLL()
	arrt = RLL()
	res = [0] * n
	dif = [0] * n
	sm = [0]
	for i in arrt:
		sm.append(sm[-1] + i)
	for i in range(n):
		now = arrv[i] + sm[i]
		p = bisect_right(sm, now)
		if p - 1 >= 0:
			res[i] += 1
			if p <= n:
				res[p - 1] -= 1
		if p <= n:
			dif[p - 1] += now - sm[p - 1]
	for i in range(1, n):
		res[i] += res[i - 1]
	for i in range(n):
		res[i] *= arrt[i]
		res[i] += dif[i]
	print(*res)
main()


import sys
from bisect import bisect_left

def printf(format, *args):
	sys.stdout.write(format % args)

def puts(string):
	print(string)
n = int(input())
v = [int(x) for x in input().split()]
T = [int(x) for x in input().split()]
S = [0] * (n + 1)
ans = [0] * (n + 1)
extra = [0] * (n + 1)
for i in range(n):
	if i - 1 >= 0:
		S[i] = S[i - 1] + T[i]
	else:
		S[i] = T[i]
S[n] = 10 ** 20
for i in range(n):
	restar = 0
	if i > 0:
		restar = S[i - 1]
	lo = bisect_left(S, v[i] + restar, lo=i)
	ans[i] += 1
	if lo == n:
		continue
	ans[lo] -= 1
	if lo > 0:
		extra[lo] += v[i] - S[lo - 1] + restar
	else:
		extra[lo] += v[i] + restar
for i in range(n):
	if i - 1 >= 0:
		ans[i] += ans[i - 1]
for i in range(n):
	ans[i] = ans[i] * T[i] + extra[i]
print(' '.join(map(str, ans[0:n])))


def bin_search_base(arr, val, base_index):
	lo = base_index
	hi = len(arr) - 1
	while lo < hi:
		if hi - lo == 1 and arr[lo] - arr[base_index] < val < arr[hi] - arr[base_index]:
			return lo
		if val >= arr[hi] - arr[base_index]:
			return hi
		c = (hi + lo) // 2
		if val < arr[c] - arr[base_index]:
			hi = c
		elif val > arr[c] - arr[base_index]:
			lo = c
		else:
			return c
	return lo
n = int(input())
volumes = list(map(int, input().split()))
temps = list(map(int, input().split()))
temp_prefix = [0]
for i in range(n):
	temp_prefix.append(temps[i] + temp_prefix[i])
gone_count = [0] * (n + 1)
remaining_count = [0] * n
gone_volume = [0] * (n + 1)
for i in range(n):
	j = bin_search_base(temp_prefix, volumes[i], i)
	gone_count[j] += 1
	gone_volume[j] += volumes[i] - (temp_prefix[j] - temp_prefix[i])
for i in range(n):
	remaining_count[i] = 1 + remaining_count[i - 1] - gone_count[i]
for i in range(n):
	gone_volume[i] += remaining_count[i] * temps[i]
print(' '.join(map(str, gone_volume[:n])))


import heapq
from bisect import bisect_left, bisect_right
from collections import Counter
from collections import OrderedDict
from collections import deque
from itertools import accumulate, product
import math
R = lambda : map(int, input().split())
n = int(input())
snows = list(R())
melts = list(R())
acc = list(accumulate(melts))
(cnt, rem) = ([0] * n, [0] * n)
for (i, s) in enumerate(snows):
	ri = bisect_right(acc, s + (acc[i - 1] if i > 0 else 0))
	cnt[i] += 1
	if ri < n:
		cnt[ri] -= 1
		rem[ri] += s + (acc[i - 1] if i > 0 else 0) - (acc[ri - 1] if ri > 0 else 0)
cnt = list(accumulate(cnt))
for i in range(n):
	print(melts[i] * cnt[i] + rem[i], end=' ')


from __future__ import print_function
from itertools import permutations as perm
from collections import *
from sys import stdin
from bisect import *
from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(n,) = gil()
(a, t) = (gil(), gil())
pre = t[:]
for i in range(1, n):
	pre[i] += pre[i - 1]

def getSum(l, r):
	v = pre[r]
	if l:
		v -= pre[l - 1]
	return v
c = [0] * n
f = [0] * n
for l in range(n):
	if a[l] <= t[l]:
		c[l] += a[l]
	else:
		f[l] += 1
		(li, ri) = (l, n - 1)
		R = l
		while li <= ri:
			mid = (li + ri) // 2
			if a[l] >= getSum(l, mid):
				R = mid
				li = mid + 1
			else:
				ri = mid - 1
		if R + 1 < n:
			c[R + 1] += max(0, a[l] - getSum(l, R))
			f[R + 1] -= 1
for i in range(1, n):
	f[i] += f[i - 1]
for i in range(n):
	f[i] *= t[i]
	f[i] += c[i]
print(*f, sep=' ')


import heapq
import sys
heap = []
n = int(input())
V = list(map(int, input().split()))
T = list(map(int, input().split()))
tmp = 0
j = 0
for i in range(n):
	ans = 0
	heapq.heappush(heap, tmp + V[i])
	while len(heap) and heap[0] <= tmp + T[i]:
		ans += heapq.heappop(heap) - tmp
	tmp += T[i]
	ans += T[i] * len(heap)
	print(ans, end=' ')
	j += 1
	if j == 10000:
		sys.stdout.flush()
		j = 0


def findMaxTemp(psT, v, start, minus):
	l = start - 1
	r = len(psT)
	while r - l > 1:
		m = l + (r - l) // 2
		val = psT[m] - minus
		if val < v:
			l = m
		else:
			r = m
	return (l, r)

def solve():
	N = int(input())
	V = list(map(int, input().split()))
	T = list(map(int, input().split()))
	ans = [0 for _ in range(N)]
	partialAns = [0 for _ in range(N)]
	cnt = [0 for _ in range(N)]
	minus = 0
	psT = T[:]
	for i in range(1, N):
		psT[i] += psT[i - 1]
	for i in range(len(V)):
		(l, r) = findMaxTemp(psT, V[i], i, minus)
		if r == i:
			partialAns[r] += V[i]
		elif r == len(psT):
			cnt[i] += 1
		else:
			cnt[i] += 1
			cnt[l + 1] -= 1
			value = V[i] - (psT[l] - minus)
			partialAns[r] += value
		minus = psT[i]
	for i in range(1, N):
		cnt[i] += cnt[i - 1]
	for i in range(N):
		ans[i] += partialAns[i]
		ans[i] += cnt[i] * T[i]
	return ans
for x in solve():
	print(x, end=' ')


n = int(input())
v = list(map(int, input().split()))
t = list(map(int, input().split()))
sumv = list()
sumv.append(0)
for i in range(n):
	sumv.append(sumv[i] + v[i])
sumt = list()
sumt.append(0)
for i in range(n):
	sumt.append(sumt[i] + t[i])
ans = [0] * n
add = [0] * (n + 1)
for i in range(n):
	if v[i] <= t[i]:
		ans[i] += v[i]
	elif v[i] >= sumt[n] - sumt[i]:
		add[i] += 1
	else:
		l = i + 1
		r = n
		mid = (r + l) // 2
		while r > l:
			mid = (r + l) // 2
			if sumt[mid] - sumt[i] == v[i]:
				r = mid
				break
			elif sumt[mid] - sumt[i] > v[i]:
				r = mid
			else:
				l = mid + 1
		ans[r - 1] += v[i] - sumt[r - 1] + sumt[i]
		add[i] += 1
		add[r - 1] -= 1
tmpcnt = 0
for i in range(n):
	tmpcnt += add[i]
	ans[i] += tmpcnt * t[i]
print(' '.join((i for i in map(str, ans))))


from sys import stdin

def binary_search(l, r, val):
	global prefix
	(i, j) = (l, r)
	while i < j:
		mid = (i + j) // 2
		ptr = prefix[mid]
		if ptr <= val:
			i = mid + 1
		else:
			j = mid
	return i
n = int(stdin.buffer.readline())
V = list(map(int, stdin.buffer.readline().split()))
T = list(map(int, stdin.buffer.readline().split()))
cnt = [0] * (n + 1)
res = [0] * (n + 1)
prefix = [0] * (n + 1)
for i in range(n):
	if i == 0:
		prefix[i] = T[i]
	else:
		prefix[i] = prefix[i - 1] + T[i]
for i in range(n):
	id = None
	if i == 0:
		id = binary_search(i, n - 1, V[i])
	else:
		id = binary_search(i, n - 1, V[i] + prefix[i - 1])
	if id == n - 1 and V[i] + prefix[i - 1] > prefix[id]:
		id += 1
	cnt[i] += 1
	cnt[id] -= 1
	if id == n:
		continue
	if i == 0:
		res[id] += T[id] - prefix[id] + V[i]
	else:
		res[id] += T[id] - prefix[id] + V[i] + prefix[i - 1]
for i in range(n):
	if i > 0:
		cnt[i] += cnt[i - 1]
	res[i] += cnt[i] * T[i]
for i in range(n):
	if i == n - 1:
		print(res[i])
	else:
		print(res[i], end=' ')


from bisect import bisect_left
from itertools import accumulate
n = int(input())
v = [int(x) for x in input().split()]
t = [int(x) for x in input().split()]
ts = [0] + list(accumulate(t))
m = [1] * n
d = [0] * n
for i in range(n):
	m[i] += m[i - 1] if i > 0 else 0
	j = bisect_left(ts, v[i] + ts[i], lo=i + 1) - 1
	if j < n:
		m[j] -= 1
		d[j] += v[i] - (ts[j] - ts[i])
s = []
for i in range(n):
	s += [m[i] * t[i] + d[i]]
print(' '.join(map(str, s)))


import itertools
import operator
from bisect import bisect

def main():
	N = int(input())
	V = tuple(map(int, input().split()))
	T = tuple(map(int, input().split()))
	templ = [0] + list(itertools.accumulate(T, operator.add))
	M = [0] * (N + 2)
	lost = M[:]
	for (j, v) in enumerate(V):
		i = bisect(templ, v + templ[j])
		M[i] += v + templ[j] - templ[i - 1]
		lost[i] += 1
	F = [0] * (N + 1)
	for i in range(N):
		F[i + 1] += F[i] + 1 - lost[i + 1]
	print(*[F[i] * T[i - 1] + M[i] for i in range(1, N + 1)], sep=' ')
main()


from math import *
from collections import *

def bs(x, i):
	l = i
	r = n - 1
	if i != 0:
		while l <= r:
			mid = (l + r) // 2
			if mid == n - 1:
				return mid
			if pre[mid] - pre[i - 1] > x and pre[mid - 1] - pre[i - 1] < x:
				return mid
			if pre[mid] - pre[i - 1] == x:
				return mid
			if pre[mid] - pre[i - 1] > x:
				r = mid - 1
			else:
				l = mid + 1
	else:
		while l <= r:
			mid = (l + r) // 2
			if mid == n - 1:
				return mid
			if pre[mid] > x and pre[mid - 1] < x:
				return mid
			if pre[mid] == x:
				return mid
			if pre[mid] > x:
				r = mid - 1
			else:
				l = mid + 1
	return mid
n = int(input())
l = list(map(int, input().split()))
t = list(map(int, input().split()))
pre = [t[0]]
for i in range(1, n):
	pre.append(pre[i - 1] + t[i])
dis = [0 for i in range(n)]
val = [0 for i in range(n)]
for i in range(n):
	dis[i] = bs(l[i], i)
	if dis[i] > 0:
		if i > 0:
			if l[i] > pre[dis[i]] - pre[i - 1]:
				val[dis[i]] += t[dis[i]]
			else:
				val[dis[i]] += l[i] - pre[dis[i] - 1] + pre[i - 1]
		elif l[i] > pre[dis[i]]:
			val[dis[i]] += t[dis[i]]
		else:
			val[dis[i]] += l[i] - pre[dis[i] - 1]
	elif l[i] > pre[dis[i]]:
		val[dis[i]] += t[dis[i]]
	else:
		val[dis[i]] += l[0]
ans = [0 for i in range(n)]
for i in range(n):
	ans[i] += 1
	ans[dis[i]] -= 1
for i in range(1, n):
	ans[i] += ans[i - 1]
for i in range(n):
	ans[i] *= t[i]
	ans[i] += val[i]
for i in ans:
	print(i, end=' ')
print()


from sys import stdin, stdout
from bisect import bisect

def rint():
	return map(int, stdin.readline().split())
N = int(input())
V = list(rint())
T = list(rint())
TT = [T[0]]
for i in range(1, N):
	TT.append(TT[i - 1] + T[i])
D = [0 for i in range(N)]
M = [0 for i in range(N)]
TT.append(0)
for i in range(0, N):
	j = bisect(TT, V[i] + TT[i - 1], i, N)
	if j >= N:
		continue
	D[j] += 1
	M[j] = M[j] + V[i] - (TT[j - 1] - TT[i - 1])
for i in range(1, N):
	D[i] += D[i - 1]
ans = [0 for i in range(N)]
for i in range(N):
	ans[i] = T[i] * (i + 1 - D[i]) + M[i]
print(*ans)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
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 findMaxTemp(psT, v, start, minus):
	l = start - 1
	r = len(psT)
	while r - l > 1:
		m = l + (r - l) // 2
		val = psT[m] - minus
		if val < v:
			l = m
		else:
			r = m
	return (l, r)

def solve():
	N = int(input())
	V = list(map(int, input().split()))
	T = list(map(int, input().split()))
	ans = [0 for _ in range(N)]
	partialAns = [0 for _ in range(N)]
	cnt = [0 for _ in range(N)]
	minus = 0
	psT = T[:]
	for i in range(1, N):
		psT[i] += psT[i - 1]
	for i in range(len(V)):
		(l, r) = findMaxTemp(psT, V[i], i, minus)
		if r == i:
			partialAns[r] += V[i]
		elif r == len(psT):
			cnt[i] += 1
		else:
			cnt[i] += 1
			cnt[l + 1] -= 1
			value = V[i] - (psT[l] - minus)
			partialAns[r] += value
		minus = psT[i]
	for i in range(1, N):
		cnt[i] += cnt[i - 1]
	for i in range(N):
		ans[i] += partialAns[i]
		ans[i] += cnt[i] * T[i]
	return ans
for x in solve():
	print(x, end=' ')


import heapq
N = int(input().strip())
V = list(map(int, input().strip().split()))
T = list(map(int, input().strip().split()))
res = []
pq = []
summ = 0
for i in range(N):
	cur = 0
	heapq.heappush(pq, summ + V[i])
	summ += T[i]
	while pq:
		item = pq[0]
		if summ < item:
			cur += len(pq) * T[i]
			break
		else:
			heapq.heappop(pq)
			cur += item - (summ - T[i])
	res.append(str(cur))
print(' '.join(res).strip())


from sys import stdin, stdout
import heapq
n = int(input())
v = list(map(int, input().split()))
t = list(map(int, input().split()))
heap = []
sum = 0
for i in range(n):
	ans = 0
	heapq.heappush(heap, sum + v[i])
	while len(heap) and heap[0] <= sum + t[i]:
		ans += heap[0] - sum
		heapq.heappop(heap)
	ans += len(heap) * t[i]
	sum += t[i]
	print(ans, end=' ')