#include<bits/stdc++.h>
using namespace std;
int parent(int i) { return i/2; }
int left(int i) { return i*2; }
int right(int i) { return i*2+1; }
int main(){
  int H,tree[100001];
  scanf("%d",&H);
  for(int i=1;i<=H;i++) scanf("%d",&tree[i]);
  for(int i=1;i<=H;i++){
    cout<<"node "<<i<<": key = "<<tree[i]<<", ";
    if(parent(i)>=1) cout<<"parent key = "<<tree[parent(i)]<<", ";
    if(left(i)<=H) cout<<"left key = "<<tree[left(i)]<<", ";
    if(right(i)<=H) cout<<"right key = "<<tree[right(i)]<<", ";
    cout<<endl;
  }
  return(0);
}

