#include<stdio.h>
#define MAX 100000
int parent(int);
int left(int);
int right(int);
int main(){
  int N,i;
  scanf("%d",&N);
  int A[MAX+1];
  for(i=1;i<=N;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=N;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=N)printf("left key = %d, ",A[left(i)]);
    else printf("\n");
    if(right(i)<=N)printf("right key = %d, \n",A[right(i)]);
    else if(left(i)<=N)printf("\n");
  }
}
int parent(int n){
  return n/2;
}
int left(int n){
  return 2*n;
}
int right(int n){
  return (2*n)+1;
}

