#C937. Minimum Employee Count Difference
Minimum Employee Count Difference
Minimum Employee Count Difference
You are given an integer n representing the number of departments and a list of n positive integers, where each integer denotes the number of employees in a department. Your task is to divide these departments into two groups such that the absolute difference between the total number of employees in the two groups is minimized.
Let \(T\) be the total number of employees across all departments and \(S\) be the sum of employee counts in one group. The goal is to choose \(S\) such that the difference \(T - 2S\) is minimized.
For example, if n = 5 and the employee counts are 10 20 15 25 30
, one optimal partition results in groups with a difference of 0.
inputFormat
The first line contains a single integer n — the number of departments.
The second line contains n space-separated positive integers representing the employee counts for each department.
outputFormat
Output a single integer representing the minimum possible absolute difference between the total numbers of employees in the two groups.
## sample5
10 20 15 25 30
0
</p>