n = gets.to_i
m = gets.split.map(&:to_i)

n.times do |i|
	answer = ""
	answer += "node #{i + 1}: key = #{m[i]}, "
	answer += "parent key = #{ m[(i + 1)/2 - 1 ]}, " if i != 0
	answer += "left key = #{m[2*i + 1]}, " if  m[2*i + 1]
	answer += "right key = #{m[2*i + 2]}, " if  m[2*i + 2]
	puts answer
end