#include<stdio.h>
#include<stdlib.h>
typedef struct{
  int id;
  int parent;
  int left;
  int right;
}Node;
int main(){
  int n,x;
  int i;
  Node *T;
  
  scanf("%d",&n);
  T=(Node*)malloc(sizeof(Node)*(n+1));
  for(i=1;i<=n;i++){//入力
    scanf("%d",&x);
    T[i].id=x;
    T[2*i].parent=x;
    T[2*i+1].parent=x;
    if(i%2==0)T[i/2].left=x;
    else T[(i-1)/2].right=x;
    }
  for(i=1;i<=n;i++){//出力
    printf("node %d: key = %d, ",i,T[i].id);
    if(T[i].parent!=0)printf("parent key = %d, ",T[i].parent);
    if(T[i].left!=0)printf("left key = %d, ",T[i].left);
    if(T[i].right!=0)printf("right key = %d, ",T[i].right);
    printf("\n");
    } 
  // printf("node 1: key = 10, left key = 8, right key = 5,\n");
  //printf("node 2: key = 8, parent key = 10, left key = 1, right key = 2,\n");
  //printf("node 3: key = 5, parent key = 10, left key = 3,\n");
  //printf("node 4: key = 1, parent key = 8,\n");
  //printf("node 5: key = 2, parent key = 8,\n");
  //printf("node 6: key = 3, parent key = 5,\n");
  return 0;
}

