#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

#define null INT_MAX

typedef struct{
  int key;
  int parent;
  int right;
  int left;
}Heep;


int main(){
  Heep H[251];
  int n, i, x;

  scanf("%d",&n);
  if( n<1 || 251<n )exit(1);

  for( i=1 ; i<=n ; i++ ){
    H[i].parent = null;
    H[i].right = null;
    H[i].left = null;
  }
  

  for( i=1 ; i<=n ; i++ ){
    scanf("%d",&H[i].key);
    if( H[i].key < -2000000000 || 2000000000 < H[i].key ) exit(2);

    if( i!=1 ){
      H[i].parent = H[i/2].key;
      
      if( i%2 == 0 ){
	H[i/2].left = H[i].key;
      }
      else{
	H[i/2].right = H[i].key;
      }
    }
  }

  for( i=1 ; i<=n ; i++ ){
    printf("node %d: key = %d, ", i , H[i].key);
    
    if( H[i].parent != null )     printf("parent key = %d, ", H[i].parent);
   
    if( H[i].left != null )       printf("left key = %d, ", H[i].left);
    
    if( H[i].right != null )      printf("right key = %d, ", H[i].right);

    printf("\n");
  }  

return 0;
}
							    