#include<stdio.h>
#define M 100000

int parent(int i){
  return i/2;
}
int left(int j){
  return 2*j;
}
int right(int k){
  return 2*k+1;
}

int main(){
  int N,i,st[M+1];

  scanf("%d",&N);
  for(i=1;i<=N;i++){
    scanf("%d",&st[i]);
  }
  for(i=1;i<=N;i++){
    printf("node %d: key = %d,",i,st[i]);
    if(parent(i)>=1)printf(" parent key = %d,",st[parent(i)]);
    if(left(i)<=N)printf(" left key = %d,",st[left(i)]);
    if(right(i)<=N)printf(" right key = %d,",st[right(i)]);
    printf(" \n");
  }
		     
  return 0;
}
