n = STDIN.gets.to_i
array = STDIN.gets.split.map(&:to_i)

array.each_with_index do |num, index|
  printf("node %d: key = %d,", index + 1, num)
  printf(" parent key = %d,", array[(index - 1) / 2]) if index != 0
  printf(" left key = %d,", array[index * 2 + 1]) if index * 2 + 1 < array.size
  printf(" right key = %d,", array[(index + 1) * 2]) if (index + 1) * 2 < array.size
  printf(" \n")
end