#include<stdio.h>
#include<stdlib.h>

#define MAX 250
#define NIL -2000000001
typedef struct node{
  int key;
  int l;
  int r;
  int p;
}Node;

Node A[MAX];
int H;

void print(int);
int parent(int);
int left(int,int);
int right(int,int);

int main(){
  int i,l,r,p,j,k;
  
  scanf("%d",&H);

  p = NIL;
  l = r = NIL-1;
  for(i = 0; i <= H; i++)A[i].p = A[i].l = A[i].r = A[i].key = NIL;//初期化
  
  for(i = 1; i <= H; i++){
    scanf("%d",&k);
    A[i].key = k;
    p = parent(i);
    if(p != NIL)A[i].p = A[p].key;
  }

  for(i = 1; i <= H; i++){
    if(left(i,H) != NIL)A[i].l = A[left(i,H)].key;
    if(right(i,H) != NIL)A[i].r = A[right(i,H)].key;
  }
  
  print(H);
  
  return 0;
}

void print(int size){
  int i;
  
  for(i = 1; i <= size; i++){
    printf("node %d: key = %d, ",i,A[i].key);
    
    if(A[i].p != NIL)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");
  }
  
}

int parent(int i){
  
  if(i <= 1)return NIL;
  return i/2;
  
}

int left(int i,int size){
  if(2*i > size)return NIL;
  return 2*i;
  
}

int right(int i,int size){
  if(2*i+1 > size)return NIL;
  return 2*i+1;
  
}
