let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let () =
  let h = read_int () in
  let t = Array.make (h + 1) 0 in
  let rec read i =
    if i <= h then (t.(i) <- Scanf.scanf "%d " (fun i -> i); read (i + 1))
  in
  read 1;
  let rec doit i =
    if i <= h then begin
      Printf.printf "node %d: key = %d, " i t.(i);
      if parent i >= 1 then Printf.printf "parent key = %d, " t.(parent i);
      if left i <= h then Printf.printf "left key = %d, " t.(left i);
      if right i <= h then Printf.printf "right key = %d, " t.(right i);
      print_newline ();
      doit (i + 1)
    end
  in
  doit 1