#include <stdio.h>

typedef struct {
  int key;
  int parent;
  int left;
  int right;
} heap;

heap H[300];

int main()
{
  int h,key,i;

  scanf("%d",&h); /* ヒープのサイズ */

  /* 初期化 */
  for(i = 0;i < h+1;i++){
    H[i].key = -2000000001;
    H[i].parent = -2000000001;
    H[i].left = -2000000001;
    H[i].right = -2000000001;
  }

  for(i = 1;i < h+1; i++){
    scanf("%d",&key);
    H[i].key = key;
  }
  for(i = 1;i < h+1; i++){
    H[i].parent = H[i/2].key; /* 親の設定 */
    if((2*i) < h+1) H[i].left = H[2*i].key; /* 左の設定 */
    if((2*i+1) < h+1) H[i].right = H[2*i+1].key; /* 右の設定 */
  }

  /* 出力 */
  for(i = 1; i < h+1; i++){
    printf("node %d: key = %d, ",i,H[i].key);
    if(H[i].parent != -2000000001) printf("parent key = %d, ",H[i].parent);
    if(H[i].left != -2000000001) printf("left key = %d, ",H[i].left);
    if(H[i].right != -2000000001) printf("right key = %d, ",H[i].right);
    printf("\n");
  }

  return 0;
}