#include<stdio.h>

#define INF 999999999

typedef long int lint;

typedef struct tree{
  lint key;
  lint parent;
  lint right;
  lint left;
}TREE;
  
int main()
{
  int i;
  lint n;
  lint key;

  TREE H[510];  
 
  scanf("%d",&n);

  for(i = 0;i < 510;i++){
    H[i].key = INF;
    H[i].left = INF;
    H[i].right = INF;
    H[i].parent = INF;
  }

  for(i = 1;i < n+1;i++){
    scanf("%ld",&key);
    H[i].key = key;
  }
  
  for(i = 1;i < n+1;i++){
    if(H[i/2].key != INF){
      H[i].parent = H[i/2].key;
    }
    if(H[i*2].key != INF){
      H[i].left = H[i*2].key;
    }
    if(H[i*2+1].key != INF){
      H[i].right = H[i*2+1].key;
    }
  }

  for(i = 1;i < n+1;i++){
    printf("node %d: ",i);

    printf("key = %ld, ",H[i].key);
    
    if(H[i].parent != INF){
      printf("parent key = %ld, ",H[i].parent);
    }
    if(H[i].left != INF){
      printf("left key = %ld, ",H[i].left);
    }
    if(H[i].right != INF){
      printf("right key = %ld, ",H[i].right);
    }
    printf("\n");
  }
  
  return 0;
}

