#include <stdio.h>

#define N 255
#define NIL -2000001

typedef struct{
  int key;
  int right,left,parent;
}Node;

Node T[N];
int A[N];
int n;

void makeTree(Node *,int *);
void print(Node *);

int main(){

  int i;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  makeTree(T,A);

  print(T);

  return 0;
}



void makeTree(Node T[],int A[]){
  int i;

  for(i=0;i<n;i++){
    T[i].key = NIL;
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right =NIL;
  }
  
  for(i=0;i<n;i++){
    T[i].key = A[i];
    if(i>0)T[i].parent = A[(i-1)/2];
    if(2*(i+1)<=n)T[i].left = A[2*(i+1)-1];
    if(2*(i+1)<=n)T[i].right = A[2*(i+1)];
  }
}

void print(Node T[]){
  int i;
  for(i=0;i<n;i++){
    printf("node %d: ",i+1);
    printf("key = %d, ",T[i].key);
    if(T[i].parent != NIL)printf("parent key = %d, ",T[i].parent);
    if(T[i].left != NIL)printf("left key = %d, ",T[i].left);
    if(T[i].right != NIL)printf("right key = %d, ",T[i].right);
    printf("\n");
  }
}