Minimum difference - MarisaOJ: Marisa Online Judge

Minimum difference

Time limit: 1000 ms
Memory limit: 256 MB
You are given an array $A$ of $n$ integers. Divide $A$ into 2 sets of numbers so that the absolute difference in their sum is as small as possible. ### Input - The first line contains an integer $n$. - The second line contains $n$ integers $A_i$. ### Output - Print the minimum difference. ### Constraints - $1 \le n \le 40$. - $-10^9 \le A_i \le 10^9$. ### Example Input: ``` 3 1 2 4 ``` Output: ``` 1 ```