#K59847. Partition Teams with Minimum Skill Disparity

    ID: 30955 Type: Default 1000ms 256MiB

Partition Teams with Minimum Skill Disparity

Partition Teams with Minimum Skill Disparity

You are given n employees and a list of their skill levels. Your task is to split these employees into two teams such that the absolute difference between the total skill levels of the two teams is minimized.

Let \( S \) be the sum of all skill levels. If one team has a total skill level of \( j \), then the other team has a total skill level of \( S - j \) and the difference is \(|S - 2j|\). Your goal is to choose a subset of employees so that \(|S - 2j|\) is as small as possible.

This is a classic dynamic programming problem where you determine possible subset sums and then select the optimal one.

inputFormat

The first line of input contains an integer n denoting the number of employees.

The second line contains n space-separated integers representing the skill levels of the employees.

outputFormat

Output a single integer which is the minimum possible difference between the total skill levels of the two teams.

## sample
1
5
5

</p>