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

void insert(int*,int,int);
void initialize(int*,int);
void print(int*,int);

int main(){
  int H;
  int key;
  int i;
  int *A;

  scanf("%d",&H);
  A=(int*)malloc((H*H)*sizeof(int));
  initialize(A,H);
  for(i=1;i<=H;i++){
    scanf("%d",&key);
    insert(A,key,i);
  }

  print(A,H);

  return 0;
}

void initialize(int* A,int h){
  for(int i=0;i<=h*h;i++){
    A[i]=0;
  }
}

void insert(int* A,int key,int i){
  A[i]=key;
}

void print(int* A,int H){
  int i;
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(A[i/2]!=0) printf("parent key = %d, ",A[i/2]);
    if(A[2*i]!=0) printf("left key = %d, ",A[2*i]);
    if(A[2*i+1]!=0) printf("right key = %d, ",A[2*i+1]);
    
    printf("\n");
  }
}

