#include <stdio.h>
#include <stdlib.h>
#define H 252
#define NIL -1
typedef struct node{
  int k;
  int pk;
  int lk;
  int rk;
}Node;

int n;
int A[H];

int main(){
  int i,n;
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }

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

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}



