N=gets.to_i
a=gets.split
a.each_with_index { |e, i|
  i=i+1
  print "node #{i}: key = #{e}, "
  print "parent key = #{a[i/2-1]}, " unless i==1
  if (i=i*2) <= N
    print "left key = #{a[i-1]}, "
    print "right key = #{a[i]}, " if i+1<=N
  end
  puts
}