module Main where

import Debug.Trace
import Data.List
import qualified Data.Sequence as S
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Char
import Data.Array
import Data.Maybe
import qualified Data.Map as M
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad
import Text.Printf

solve :: Int -> [Int] -> [(Int, Int, Maybe Int, Maybe Int, Maybe Int)]
solve n l = iter 1 where
    iter i
        | i <= n = (i,
                    heap!i,
                    if parentIdx > 0      then Just (heap!parentIdx)     else Nothing,
                    if leftChildIdx <= n  then Just (heap!leftChildIdx)  else Nothing,
                    if rightChildIdx <= n then Just (heap!rightChildIdx) else Nothing):iter (i+1)
        | i >  n =  [] where
            parentIdx = div i 2
            leftChildIdx  = 2*i
            rightChildIdx = leftChildIdx + 1
    heap = listArray (1, n) l

readIntLn:: IO Int
readIntLn = (fst . fromJust . B.readInt) <$> B.getLine

readIntList:: IO [Int]
readIntList = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

print':: (Int, Int, Maybe Int, Maybe Int, Maybe Int) -> IO ()
print' (id, k, Nothing, Nothing, Nothing) = printf "node %d: key = %d, \n" id k
print' (id, k, Nothing, Just lk, Nothing) = printf "node %d: key = %d, left key = %d,  \n" id k lk
print' (id, k, Nothing, Just lk, Just rk) = printf "node %d: key = %d, left key = %d, right key = %d, \n" id k lk rk
print' (id, k, Just pk, Nothing, Nothing) = printf "node %d: key = %d, parent key = %d, \n" id k pk
print' (id, k, Just pk, Just lk, Nothing) = printf "node %d: key = %d, parent key = %d, left key = %d, \n" id k pk lk
print' (id, k, Just pk, Just lk, Just rk) = printf "node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n" id k pk lk rk
    
main :: IO() 
main = do
    n <- readIntLn
    l <- readIntList
    mapM_ print' $ solve n l

