#include<stdio.h>
#define N 251

typedef struct{
  int key;
  int par;
  int left;
  int right;
}node;

void ndset(int,int);

node T[N];

int main(){
  int n,i;

  scanf("%d",&n);

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

  for(i=0; i<n; i++) scanf("%d",&T[i].key);
  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);
    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;
}