A depot offers delivery slots at n distinct integer times. Starting from an empty binary search tree, insert the slot times 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.
For each of q requested times t, the driver is assigned the floor slot: the largest existing slot time that is less than or equal to t. The shortfall of that request is t - floor. If no slot time is less than or equal to t, that request is unreachable and contributes 0 to the total (it is not counted as -1).
Report the sum of shortfalls over all q requests.
Input format
Line 1: an integer n.
Line 2: n space-separated distinct integers — the slot times, in insertion order.
Line 3: an integer q.
Line 4: q space-separated integers t_1 ... t_q — the requested times.
Output format
A single integer: the total shortfall summed across all requests.
Constraints
- 1 ≤ n ≤ 40
- -500 ≤ each slot time ≤ 500, all slot times distinct
- 1 ≤ q ≤ 40
- -700 ≤ t_i ≤ 700