H = gets.chomp.to_i
array = gets.chomp.split(" ").map(&:to_i)

array.each_with_index do |num,i|
  i = i+1
  parent = i/2
  left = 2*i
  right = 2*i+1
  output = "node #{i}: key = #{num}, "
  if(parent >= 1)
    output = output + "parent key = " + array[parent-1].to_s + ", "
  end
  if(left <= H)
    output = output + "left key = " + array[left-1].to_s + ", "
  end
  if(right <= H)
    output = output + "right key = " + array[right-1].to_s + ", "
  end
  puts(output)
end

