n = gets.to_i
tree = gets.split.map { |i| i.to_i }
(1..n).each do |i|
  parent = (tree[i/2-1] && i/2-1 != -1) ? "parent key = #{tree[i/2-1]}, " : ""
  left = tree[i*2-1] ? "left key = #{tree[i*2-1]}, " : ""
  right = tree[i*2] ? "right key = #{tree[i*2]}, " : ""
  puts "node #{i}: key = #{tree[i-1]}, #{parent}#{left}#{right}"
end