#K94462. Minimizing the Weight Difference

    ID: 38647 Type: Default 1000ms 256MiB

Minimizing the Weight Difference

Minimizing the Weight Difference

You are given a set of items, each with an integer weight. Your task is to distribute these items into two bags such that the absolute difference between the total weights of the two bags is minimized. Formally, let the total weight be \(W\) and let one bag's weight be \(w\), then you need to minimize \(|W - 2w|\).

Input Format: The first line contains an integer \(n\) representing the number of items. The second line contains \(n\) space-separated integers representing the weights of the items.

Output Format: Print a single integer representing the minimum absolute difference between the total weights of the two bags.

Example:

Input:
5
3 1 4 2 2

Output: 0

</p>

inputFormat

The first line of input contains an integer \(n\) (the number of items). The second line contains \(n\) space-separated integers representing the weights of each item.

outputFormat

Output a single integer representing the minimum absolute difference between the total weights of the two bags.

## sample
5
3 1 4 2 2
0