A product catalog is indexed by a binary tree of integer keys. You must decide whether the tree is a strict binary search tree (BST): for every node, every key in its left subtree is strictly less than the node's key, and every key in its right subtree is strictly greater than the node's key. Duplicate keys are therefore never allowed.
The tree is given in level-order (breadth-first) form: the tokens list the root, then the children of each node left-to-right, using the token null for a missing child. Trailing null tokens are omitted.
Input format
Line 1: an integer n, the number of level-order tokens.
Line 2: n space-separated tokens, each either an integer key or the literal null. The first token is the root and is never null.
Output format
Print YES if the tree is a strict BST, otherwise print NO.
Constraints
- 1 <= n <= 60
- Each integer key has absolute value <= 1000000.
- The tokens form a valid level-order encoding of a non-empty binary tree.