#include <stdio.h>
#include <stdlib.h>
#define INF -10000000
void maxheapfy(int *,int );
int left(int);
int right(int);
int parent(int);
int n;
int main() {

  int i;
  int *A;

  A=malloc(sizeof(int)*(n+1));

  scanf("%d",&n);
  for(i=1;i<n+1;i++) scanf("%d",&A[i]);

  

  for(i=1;i<n+1;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)]);
    if(right(i)<=n)  printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  free(A);
  return 0;
}
void maxheapfy(int *A,int i)
{
  int j;
  int l;
  int r;
  int largest;
  while(1){
  l=left(i);
  r=right(i);

  if(l<=n && A[l]>A[i]) largest=l;
  else largest=i;

  if(r<=n && A[r]>A[largest]) largest=r;

  if(largest==i) break;
  j=A[largest];
  A[largest]=A[i];
  A[i]=j;


  }
}
int left(int i)
{
  return 2*i;
}
int right(int i)
{
  return 2*i+1;
}
int parent(int i)
{
  return i/2;
}