class Array
	def at(index)
		return nil if index < 0
		self[index]
	end
end

# indexは0オリジン
def description(heap, index)
	key             = heap.at(index)
	parent_key      = heap.at((index + 1) / 2 - 1)
	left_child_key  = heap.at(2 * index + 1)
	right_child_key = heap.at(2 * index + 2)

	desc  = "node #{index + 1}: "
	desc += "key = #{key}, " if key
	desc += "parent key = #{parent_key}, " if parent_key
	desc += "left key = #{left_child_key}, " if left_child_key
	desc += "right key = #{right_child_key}, " if right_child_key

	desc
end

n = STDIN.gets.to_i
heap = STDIN.gets.split[0...n].map(&:to_i)
heap.each_index { |i| puts description(heap, i) }