#include<stdio.h>
#define N 250

typedef struct{
  int p;
  int l;
  int r;
  int k;
}Node;

Node node[N];

int main(){
  int i,n;
  scanf("%d",&n);
  
  for(i = 1; i < n+1; i++){
    scanf("%d",&node[i].k);
  }
  
  for(i = 1; i < n+1; i++){
    if(i == 1){
      node[i].p = -1;
    }else{
      node[i].p = i/2;
    }
    if(2*i > n){
      node[i].l = node[i].r = -1;
    }else{
      node[i].l = 2*i;
    }
    if(2*i+1 > n){
      node[i].r = -1;
    }else{
      node[i].r = 2*i+1;
    }
  }
  for(i = 1; i < n+1;i++){
    printf("node %d: key = %d, ",i,node[i].k);
    if(node[i].p != -1){
      printf("parent key = %d, ",node[node[i].p].k);
    }
    if(node[i].l != -1){
      printf("left key = %d, ",node[node[i].l].k);
    }
    if(node[i].r != -1){
      printf("right key = %d, ",node[node[i].r].k);
    }
    printf("\n");
    
  }
  return 0;
}