#include<stdio.h>


void heap(int id,int n,int A[]);
int main(){
  int n,i,j;
  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  j=1;
  for(i=0;i<n;i++){
    heap(j, n, A);
    if(i<n-1)printf("\n");
    j++;
  }
}

void heap(int id, int n, int A[]){
  int pid,cid;
  pid = id/2;
  cid = id*2;
  if(pid<1&&cid<=n){
    printf("node %d: key = %d, left key = %d, right key = %d, ",id,A[id-1], A[id*2-1], A[id*2]);
  }else if(pid>=1&&cid<n){
    printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, ",id,A[id-1],A[pid-1], A[id*2-\
1], A[id*2]);
  }else if(pid>=1&&cid==n){
    printf("node %d: key = %d, parent key = %d, left key = %d, ",id,A[id-1],A[pid-1], A[id*2-1]);
  }else if(pid>=1&&cid>n){
    printf("node %d: key = %d, parent key = %d, ",id,A[id-1],A[pid-1]);
  }
}



