ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Сборники > Алгоритмы и Структуры Данных > задача:


23. Apple Division

Задачи сборника

• 15. Bit Strings
• 16. Josephus Queries
• 17. Number Spiral
• 18. Apartments
• 19. Ferris Wheel
• 20. Two Sets
• 21. Distinct Numbers
• 22. Creating Strings
• 23. Apple Division
• 24. Coin Piles
• 25. Josephus Queries
• 26. Exponentiation
• 27. Dice Combinations
• 28. Minimizing Coins
• 29. Coin Combinations I
• 30. Distinct Numbers
• 31. Apartments

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Сложность Бета


There are n apples with known weights. Your task is to divide the apples into two groups so that the difference between the weights of the groups is minimal

Input

The first input line has an integer n: the number of apples.

The next line has n integers p1,p2,…,pn: the weight of each apple.

Output

Print one integer: the minimum difference between the weights of the groups.

Constraints
1≤n≤20
1≤pi≤109

Example
Input:
5
3 2 7 4 1

Output:
1

Explanation:
Group 1 has weights 2, 3 and 4 (total weight 9), and group 2 has weights 1 and 7 (total weight 8).

Для отправки решений необходимо выполнить вход.

www.contester.ru