#include<stdio.h>
#define N 250 //max nodes is up to 250

typedef struct{
  int key; //key
  int par; //parrent
  int left; //left side
  int right; //right side
}node;



node T[N]; //identifying each nodes 

int main(){
  int n,i;

  scanf("%d",&n); //input needed node numbers

  for(i=0; i<n; i++) T[i].par = -1; //

  for(i=0; i<n; i++){
    scanf("%d",&T[i].key); //input quantity of keys with space between
  }


  for(i=0; i<n; i++){

    if(i != 0) T[i].par = (i+1)/2-1;

    if(2*(i+1)-1 < n) T[i].left = 2*(i+1)-1;
    else T[i].left = -1;

    if(2*(i+1) < n) T[i].right = 2*(i+1);
    else T[i].right = -1;

  }

  for(i=0; i<n; i++){

    printf("node %d: key = %d, ", i+1, T[i].key);
    //moveing order 
    if(T[i].par != -1) printf("parent key = %d, ",T[T[i].par].key); //
    if(T[i].left != -1) printf("left key = %d, ",T[T[i].left].key); 
    if(T[i].right != -1) printf("right key = %d, ",T[T[i].right].key);

    printf("\n");

  }

  return 0;
}