H = gets.chomp.to_i
hKeys = gets.chomp.split(' ').map(&:to_i)
hKeys.unshift(nil)

(1..H).each do |i|
    print "node #{i}: key = #{hKeys[i]}, "
    print "parent key = #{hKeys[(i / 2)]}, " if i / 2.0 >= 1
    print "left key = #{hKeys[i * 2]}, " if i * 2 <= H
    print "right key = #{hKeys[i * 2 + 1]}, " if i * 2 + 1 <= H
    print "\n"
end
