def solve arr
  arr.each_with_index do |num, ind|
    printf("node %d: key = %d,", ind + 1, num)
    printf(" parent key = %d,", arr[(ind - 1) / 2]) if ind != 0
    printf(" left key = %d,", arr[ind * 2 + 1]) if ind * 2 + 1 < arr.size
    printf(" right key = %d,", arr[ind * 2 + 2]) if ind * 2 + 2 < arr.size
    puts
  end
end

def main
  n = gets.to_i
  arr = gets.split(/\s/).map(&:to_i)
  solve(arr)
end

main