using System;
using System.Collections.Generic;
using System.Text;

class Program
{

    public void Proc()
    {
        int itemCount = int.Parse(Console.ReadLine());
        string[] inpt = Console.ReadLine().Split(' ');
        for (int i = 0; i < itemCount; i++)
        {
            long target = long.Parse(inpt[i]);
            TreeNd.AddItem(i +1, target);
        }
        TreeNd.Print();
        
    }


    public class TreeNd
    {
        public long Key;
        public int Node;
        public int Depth = 0;
        public TreeNd Parent;
        public TreeNd LeftChild;
        public TreeNd RightChild;



        private static List<List<TreeNd>> dic = new List<List<TreeNd>>();
        public static TreeNd Root;

        public TreeNd(int node, long target)
        {
            this.Key = target;
            this.Node = node;
        }

        public static void AddItem(int node, long target) {
            if (Root == null)
            {
                Root = new TreeNd(node, target);
                dic.Add(new List<TreeNd>());
                dic[0].Add(Root);
            }
            else
            {
                int maxNum = (int)Math.Pow(2, dic.Count - 1);
                if (dic[dic.Count-1].Count < maxNum)
                {
                    List<TreeNd> items = dic[dic.Count - 2];
                    for (int i = 0; i < items.Count; i++)
                    {
                        if (items[i].CanAdd())
                        {
                            TreeNd newItem = items[i].Add(node, target);
                            dic[dic.Count - 1].Add(newItem);
                            break;
                        }
                    }
                }
                else
                {
                    TreeNd newItem = dic[dic.Count - 1][0].Add(node, target);
                    dic.Add(new List<TreeNd>());
                    dic[dic.Count - 1].Add(newItem);
                }
            }
        }
        public static void Print()
        {
            for (int i = 0; i < dic.Count; i++)
            {
                for (int j = 0; j < dic[i].Count; j++)
                {
                    Console.WriteLine(dic[i][j].ToString());
                }
            }
        }

        public bool CanAdd()
        {
            return (this.LeftChild == null || this.RightChild == null);
        }
        public TreeNd Add(int node, long target)
        {
            TreeNd newItem = new TreeNd(node, target);
            newItem.Parent = this;
            newItem.Depth = this.Depth + 1;
            if (this.LeftChild == null)
            {
                this.LeftChild = newItem;
            }
            else if (this.RightChild == null)
            {
                this.RightChild = newItem;
            }
            return newItem;
        }

        public override string ToString()
        {
            // node 1: key = 7, left key = 8, right key = 1, 
            StringBuilder sb = new StringBuilder();
            sb.Append("node " + this.Node + ": key = " + this.Key + ", ");
            if (this.Parent != null)
            {
                sb.Append("parent key = " + this.Parent.Key + ", ");
            }
            if (this.LeftChild != null)
            {
                sb.Append("left key = " + this.LeftChild.Key + ", ");
            }
            if (this.RightChild != null)
            {
                sb.Append("right key = " + this.RightChild.Key + ", ");
            }

            return sb.ToString();
        }
    }



    static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 9728