#include <stdio.h>

#define MAX_H 250

struct Node{
  int id; //node id
  int k; // node key
  int pk; //parent node key
  int lk; //left node key
  int rk; //right node key
};

int main (void)
{
  int i,h;
  struct Node a[MAX_H + 1];

  scanf ("%d",&h);
  if (h <= MAX_H)
    for (i = 1 ; i < h+1 ; i++){
      scanf ("%d",&a[i].k);
    }

  for (i = 1 ; i < h+1 ; i++){
    a[i].id = i;
    if (i != 1)
      a[i].pk = i / 2;
    if (h >= i * 2)
      a[i].lk = i * 2;
    if (h >= i * 2 + 1)
      a[i].rk = i * 2 + 1;
  }

  for (i = 1 ; i < h+1 ; i++){
    printf ("node %d: key = %d, ",a[i].id,a[i].k);
    if (i != 1)
      printf ("parent key = %d, ",a[a[i].pk].k);
    if (h >= i * 2)
      printf ("left key = %d, ",a[a[i].lk].k);
    if (h >= i * 2 + 1)
      printf ("right key = %d, ",a[a[i].rk].k);
    printf ("\n");
  }

  return 0;
}