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

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