function main(_stdin) {
    const stdin = _stdin.trim().split('\n');
    const H = Number(stdin.shift());
    const A = stdin.shift().split(' ').map(Number);

    for (let i = 0; i < H; i++) {
        const id = i + 1;
        const parent = id !== 1 ? Math.floor(id / 2 - 1) : null;
        const left = id * 2 <= H ? id * 2 - 1 : null;
        const right = id * 2 + 1 <= H ? id * 2 : null;

        let out = `node ${id}: `;
        out += `key = ${A[i]}, `;
        out += parent !== null ? `parent key = ${A[parent]}, ` : '';
        out += left !== null ? `left key = ${A[left]}, ` : '';
        out += right !== null ? `right key = ${A[right]}, ` : '';
        console.log(out);
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

