def read_tree(a)
  def parent(array, index)
		if(index != 1)
		  "parent key = #{array[index/2]},"
		end
	end
	def keys(array, index)
		left = 2*index
		right = 2*index + 1
		if(left < array.length && right < array.length)
			"left key = #{array[left]}, right key = #{array[right]}"
		elsif(left < array.length && right >= array.length)
			"left key = #{array[left]}" 
		elsif(right < array.length && left >= array.length)
			"right key = #{array[right]}" 
		end 
	end
  a.insert(0,0)
	for i in 1...(a.length)
   puts "node #{i}: key = #{a[i]}, #{parent(a, i)} #{keys(a, i)}"
  end
end

array = gets.chomp
array = gets.chomp
array = array.split().map(&:to_i)
read_tree(array);