IBMOA #12
Card Packets
Estimated MediumJudge-ready
Topics (AI-labelled)Bits & Math
There are several kinds of cards, each with a given count. Choose at least 2 packs and, only by adding cards, make every kind of card split evenly among all packs. Find the minimum total number of cards to add.
Input
The first line contains n, and the second line contains n counts. 1≤n≤100000, 1≤count≤500.
Output
Output one integer, the answer.
Example 1
Input:
2
1 1
Output:
2
Example 2
Input:
3
2 4 6
Output:
0
Example 3
Input:
2
3 4
Output:
1
Example notes
The examples give 2, 0 and 1 respectively.
Editorial
Loading solution…