#include <stdio.h>
#define nil -1
#define max 251
typedef struct{
  int key;
  int parent;
  int right;
  int left;
} node;
int parent(int);
int left(int);
int right(int);
void PrintData(void);
int H;
node data[max];

int main()
{
  int i;

  scanf("%d",&H);

  for(i = 0 ; i < H + 1 ; i++){
    data[i].parent = nil;
    data[i].right = nil;
    data[i].left = nil; }
  
  for(i = 1 ; i < H + 1 ; i++){
    scanf("%d",&data[i].key);
    if(i != 1) data[i].parent = parent(i); 
    if(left(i) < H + 1) data[i].left = left(i);
    if(right(i) < H + 1) data[i].right = right(i); }
  
  PrintData();
  
  return 0;
}

int parent(int i)
{
  return i/2;
}

int left(int i)
{
  return 2*i;
}

int right(int i)
{
  return 2*i + 1;
}

void PrintData(void)
{
  int i;	

  for(i = 1 ; i < H + 1 ; i++){ 
    printf("node %d: key = %d, ",i, data[i].key);
    if(data[i].parent != nil) printf("parent key = %d, ",data[data[i].parent].key);
    if(data[i].left != nil) printf("left key = %d, ",data[data[i].left].key);
    if(data[i].right != nil) printf("right key = %d, ",data[data[i].right].key);
    printf("\n"); }
     
}
