#include<stdio.h>
#define NIL 0.1
#define H 250

typedef struct node{
  int parent;
  int left;
  int right;
  int key;
}Node;

Node A[H];

int parent(int);
int left(int);
int right(int);



main(){
  int n,i;

  scanf("%d",&n);

  for( i=1 ; i<=H ; i++ ){
    A[i].key = NIL;
    }


  for( i=1 ; i<=n ; i++ ){
    scanf("%d",&A[i].key);

    A[i].parent = parent(i);
    A[i].left = left(i);
    A[i].right = right(i);

  }

  for( i=1 ; i<=n ; i++ ){
  printf("node %d: key = %d, ",i,A[i].key);

  if( i != 1 )printf("parent key = %d, ",A[A[i].parent].key);
  if( A[i].left <= n )printf("left key = %d, ",A[A[i].left].key);
  if( A[i].right <= n )printf("right key = %d, ",A[A[i].right].key);
  printf("\n");
  }
  return 0;
}

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return (2*i+1);
}