heap = [nil] * 257

h = gets.to_i
gets.split().each.with_index(1) do |n, i|
  n = n.to_i
  heap[i] = n
end

(1 .. h).each do |i|
  print "node #{i}: key = #{heap[i]}, "
  if parent = heap[i / 2]
    print "parent key = #{parent}, "
  end
  if left = heap[i * 2]
    print "left key = #{left}, "
  end
  if right = heap[i * 2 + 1]
    print "right key = #{right}, "
  end
  puts ''
end

