#C729. Team Speed Partition

    ID: 51144 Type: Default 1000ms 256MiB

Team Speed Partition

Team Speed Partition

Given a set of n speeds, your task is to partition them into two teams such that the absolute difference between the sum of speeds of the two teams is minimized. Formally, let \( S = \sum_{i=1}^{n} s_i \). Find a subset with sum \( s \) that minimizes \( |S - 2s| \). This is a classic partition problem that can be solved using dynamic programming.

inputFormat

The first line of input contains an integer n, representing the number of speeds. The second line contains n space-separated integers representing the speeds.

outputFormat

Output a single integer denoting the minimum possible difference between the sum of speeds of the two teams.

## sample
4
10 20 15 5
0

</p>