gets
tree = gets.split.map(&:to_i)
tree.unshift(-114514)

def parent(i)
  i / 2
end

def left(i)
  2 * i
end

def right(i)
  2 * i + 1
end

tree.size.times do |i|
  next if i == 0
  print("node ",i,": key = ",tree[i],",") if i == 1
  print("node ",i,": key = ",tree[i],", parent key = ",tree[parent(i)],",") if i > 1
  print(" left key = ",tree[left(i)],",") if left(i) <= tree.size - 1
  print(" right key = ",tree[right(i)],",") if right(i) <= tree.size - 1
  puts " "
end
