#include <stdio.h>

int Parent(int);
int Left(int);
int Right(int);

int main(){
  int h,i,key,A[250],pn,ln,rn;
  scanf("%d",&h);
  for(i=0;i<h;i++){
    scanf("%d",&key);
    A[i+1]=key;
  }
  for(i=0;i<h;i++){
    printf("node %d: ",i+1);
    printf("key = %d, ",A[i+1]);
    if(i!=0){
      pn=Parent(i+1);
      printf("parent key = %d, ",A[pn]);
    }
    if(Left(i+1)<=h){
    ln=Left(i+1);
    printf("left key = %d, ",A[ln]);
    }
    if(Right(i+1)<=h){
    rn=Right(i+1);
    printf("right key = %d, ",A[rn]);
    }
    printf("\n");
  }
  
  return 0;
}

int Parent(int x){
  return x/2;
}
int Left(int x){
  return 2*x;
}
int Right(int x){
  return 2*x+1;
}

