# -*- coding: utf-8 -*-
class Heap
  attr_accessor :id, :key, :pk, :lk, :rk

  def initialize(id, key, max)
    @id = id.to_i + 1
    @key = key
    set_parent unless @id == 1
    set_left if @id * 2 <= max
    set_right if @id * 2 + 1 <= max
  end

  def set_parent
    @pk = id / 2
  end 

  def set_left 
    @lk = id * 2
  end

  def set_right
    @rk = id * 2 + 1
  end 

end

n = gets.to_i
keys = Array.new(n)
keys = gets.split
heap = Array.new(n)
n.times do |i|
  heap[i] = Heap.new(i,keys[i], n) 
end
n.times do |i|
  print "node ", heap[i].id, ": key = ", heap[i].key, ", "
  print "parent key = ", heap[heap[i].pk-1].key, ", " unless heap[i].pk.nil?
  print "left key = ", heap[heap[i].lk-1].key, ", " unless heap[i].lk.nil?
  print "right key = ", heap[heap[i].rk-1].key, ", " unless heap[i].rk.nil?
  puts
end