def parent(i)
	return i / 2
end

def left(i)
	return 2 * i
end

def right(i)
	return 2 * i + 1
end

H = gets.to_i
a = gets.split.map &:to_i
a.unshift(nil)

for i in 1..H do
	print("node ", i, ": key = ", a[i], ", ")
	print("parent key = ", a[parent(i)], ", ") if parent(i) >= 1
	print("left key = ", a[left(i)], ", ") if left(i) <= H
	print("right key = ", a[right(i)], ", ") if right(i) <= H
	puts
end