You are given n distinct integers. Starting from an empty binary search tree, insert them in the order given, using the standard BST rule: to insert a key x, walk down from the root, going left if x is smaller than the current node and right if x is larger, until an empty spot is reached, where a new node is created. No rebalancing is performed.
You are then given two integers lo and hi (lo ≤ hi). Count how many keys x in the tree satisfy lo < x < hi (the bounds themselves are excluded, even if they equal a key in the tree).
Input format
Line 1: an integer n.
Line 2: n space-separated distinct integers — the keys, in insertion order.
Line 3: two space-separated integers lo hi.
Output format
A single integer: the count of keys strictly between lo and hi.
Constraints
- 1 ≤ n ≤ 40
- -1000 ≤ each key ≤ 1000, all keys distinct
- -2000 ≤ lo ≤ hi ≤ 2000