#include<stdio.h>

#define H 250
#define NIL -200000

int main()
{


  int s[H], i, num;

  for(i = 0 ; i < H ; i++)
    s[i] = NIL;

  scanf("%d",&num);

  for(i = 0 ; i < num ; i++)
    scanf("%d",&s[i]);

  for(i = 0 ; i < num ; i++){
    printf("node %d: ",i+1);
    if(2*i+1 < num){
      if(i ==0 )
        printf("key = %d, left key = %d, right key = %d, \n",s[i],s[i + 1],s[i \
+2]);
      else if(s[2*(i+1)] != NIL  &&  s[2*i+1] != NIL)
        printf("key = %d, parent key = %d, left key = %d, right key = %d, \n",s\
[i],s[(i-1)/2],s[2*i+1],s[2*(i+1)]);
      else if(s[2*(i+1)] == NIL  &&  s[2*i+1] != NIL)
        printf("key = %d, parent key = %d, left key = %d, \n",s[i],s[(i-1)/2],s\
[2*i+1]);
      else
        printf("key = %d, parent key = %d, \n",s[i],s[(i-1)/2]);
    }
    else printf("key = %d, parent key = %d, \n",s[i],s[(i-1)/2]);
  }
  return 0;
}

