#K16291. Find Minimum in a Binary Search Tree

    ID: 24546 Type: Default 1000ms 256MiB

Find Minimum in a Binary Search Tree

Find Minimum in a Binary Search Tree

Given a sequence of integer values, construct a Binary Search Tree (BST) by inserting the values in the given order. In a BST, for any node, the values in the left subtree are less than the node's value. Your task is to find the minimum value in the BST by traversing to the leftmost node.

The minimum value in the BST is defined as:

$$ \min_{node \in BST} \; value(node) $$

Be sure to read the input from stdin and write your result to stdout.

inputFormat

The first line contains a single integer N, indicating the number of nodes. The second line contains N space-separated integers which are inserted into the BST in the given order.

outputFormat

Output a single integer representing the minimum value found in the BST.## sample

1
5
5