cswork / OA打开练习工作台

IBMOA #12

Card Packets

估计中等可在线判题

考点(AI 标注)位运算

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.

输入格式

The first line contains n, and the second line contains n counts. 1≤n≤100000, 1≤count≤500.

输出格式

Output one integer, the answer.

样例 1

输入:

2
1 1

输出:

2

样例 2

输入:

3
2 4 6

输出:

0

样例 3

输入:

2
3 4

输出:

1

样例说明

The examples give 2, 0 and 1 respectively.