#include<stdio.h>
#define MAX 500
#define NIL -1
struct Node{
  int p;
  int l;
  int r;
};
struct Node A[MAX];
int n,T[MAX];

int main(){
  int i,x;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    A[i].p=NIL;
    A[i].l=NIL;
    A[i].r=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d",&T[i]);
    if(i!=0){
      if(i%2==1)
	A[i].p=T[i/2];
      else A[i].p=T[i/2-1];
    }
  }
  for(i=0;i<=n/2;i++){
    if((2*i+2)<n)A[i].r=T[2*i+2];
    if((2*i+1)<n)A[i].l=T[2*i+1];
  }
  for(i=0;i<n;i++){
     printf("node %d: key = %d, ",i+1,T[i]);
    if(i!=0){
      printf("parent key = %d, ",A[i].p);
      }
    if(A[i].l!=NIL)printf("left key = %d, ",A[i].l);
    if(A[i].r!=NIL)printf("right key = %d, ",A[i].r);
    printf("\n");
  }
  return 0;
}