import math

inf = open("fenwick.in", "r")
ouf = open("fenwick.out", "w")

n = int(inf.readline())
a = map(long, inf.readline().split())

def h(s):
	r = 0
	while s % 2 == 1:
		r += 1
		s /= 2
	return r

b = map(lambda a : a, a)
for i in range(1, n):
	b[i] = b[i] + b[i - 1]
for i in range(n - 1, 0, -1):
	if i >= 2 ** h(i):
		b[i] = b[i] - b[i - 2 ** h(i)]

print a
print b

def update(j, x):
	a[j] += x
	i = j
	while i < n:
		b[i] += x
		i = i | (i + 1)

for i in range(0, int(math.log(n, 2) + 2)):
	for j in range(0, n):
		if h(j + 1) == i and j + 1 < n:
			if a[j + 1] != b[j + 1]:
				update(j, a[j + 1] - b[j + 1])

for i in a:
	ouf.write(str(i) + " ")
ouf.write("\n")

inf.close()
ouf.close()
