A reactor is balanced by selecting exactly three of its n control rods and summing their integer loads. Given a target load t, choose three rods from three different positions so that their combined load is as close to t as possible, and report the smallest achievable value of |load[i] + load[j] + load[k] - t| over all triples i < j < k. The loads are not sorted.
Input format
Line 1: an integer n.
Line 2: n space-separated integers, the rod loads.
Line 3: an integer t, the target load.
Output format
A single integer: the minimum achievable |load[i] + load[j] + load[k] - t|.
Constraints
- 3 ≤ n ≤ 4000
- -1000000000 ≤ each load ≤ 1000000000
- -3000000000 ≤ t ≤ 3000000000