#include<stdio.h>
#define MAX 250

typedef struct{
  int parent;
  int right;
  int left;
}Roll;

int main(){
  int n,i;
  int Heap[MAX];
  Roll Tree[MAX];

  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%d",&Heap[i]);
  for(i=1;i<=n;i++){
    if(i!=1) Tree[i].parent=Heap[i/2];
    else Tree[i].parent=2000000001;
    if(2*i<=n) Tree[i].left=Heap[2*i];
    else Tree[i].left=2000000001;
    if(2*i+1<=n) Tree[i].right=Heap[2*i+1];
    else Tree[i].right=2000000001;
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d,",i,Heap[i]);
    if(Tree[i].parent!=2000000001)printf("parent key = %d,",Tree[i].parent);
    if(Tree[i].left!=2000000001)printf("left key = %d,",Tree[i].left);
    if(Tree[i].right!=2000000001)printf("right key = %d,",Tree[i].right);
    printf(" \n");
  }
  return 0;
}
  