Given an array A of integers, choose 2 non-empty disjoint subsets X and Y such that ratio of sum of elements of X and Y is as close to 1 as possible.
Given,
Α : {a1, a2, .... aN}
Find,
X : {x1, x2....xK}
Y : {y1, y2.....yM}
where, X ⊂ A, Y ⊂ A, K > 0 and M > 0 and there does not exist an i, such that ai ∈ X and ai ∈ Y, and Q = abs (1.0 - Σxi / Σyi) is minimum possible. Note that there can exist i and j such that ai ∈ X and aj ∈ Y, i ≠ j but ai = aj.
Output this minimum possible value of Q with precision up to exactly 6 decimal places.
CONSTRAINTS
2 ≤ N ≤ 16
1 ≤ ai ≤ 106, ∀ i ∈ [1, N]
INPUT
The first line of test file contains a single integer N. Next line contains N space separated integers representing the array A.
OUTPUT
Print in a single line, the value of Q with exactly 6 decimal places.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial