#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdbool.h>
#define lpton(i,n) for(int i=0;i<(int)n;i++)
#define lpto0(i,n) for(int i=n;i>-1;i--)
#define lpmn(i,m,n) for(int i=m;i<n;i++)
#define ms(l,n,s) memset(l,n,s)
#define m(l,n) (l*)malloc(n*sizeof(l))
void print(int*,int);
int main(){
  int n,v;
  int *heap;
  scanf("%d",&n);
  heap=m(int,n+1);
  lpmn(i,1,n+1){
    scanf("%d",&v);
    *(heap+i)=v;
  }
  print(heap,n);
  free(heap);
  return 0;
}
void print(int *heap,int n){
  lpmn(i,1,n+1){
    printf("node %d: key = %d, ",i,*(heap+i));
    if(i/2>0)printf("parent key = %d, ",*(heap+(i/2)));
    if(i*2<n+1)printf("left key = %d, ",*(heap+(i*2)));
    if(i*2+1<n+1)printf("right key = %d, ",*(heap+(i*2+1)));
    printf("\n");
  }
}

