#K3396. Construct a Height-Balanced Binary Search Tree

    ID: 25203 Type: Default 1000ms 256MiB

Construct a Height-Balanced Binary Search Tree

Construct a Height-Balanced Binary Search Tree

You are given a sorted list of n integers in ascending order. Your task is to convert this list into a height-balanced binary search tree (BST). A BST is height-balanced if the depth of the two subtrees of every node never differs by more than 1. The construction method is to always choose the middle element as the root, then recursively build the left and right subtrees using the left and right halves of the list, respectively.

After constructing the BST, perform an inorder traversal (left subtree, root, right subtree) and print the resulting sequence. Note that, for a correctly built BST from a sorted list, the inorder traversal will reproduce the original sorted sequence.

Example:

Input:
5
-10 -3 0 5 9

Output: -10 -3 0 5 9

</p>

inputFormat

The first line contains an integer n representing the number of elements in the list. The second line contains n space-separated integers in ascending order.

outputFormat

Output the inorder traversal of the constructed BST as a space-separated sequence of numbers in one line.

## sample
5
-10 -3 0 5 9
-10 -3 0 5 9