NewThe Learning module is now liveSee what's new

A trading card company packages sports cards by type into identical packets.

Given an integer array cardTypes where cardTypes[i] represents the current inventory count of card type i, determine the minimum total number of additional cards required so that there exists an integer p >= 2 satisfying the following condition:

  • For every card type, the final count is divisible by p.

Equivalently, after adding cards, each card type can be split evenly into exactly p packets with no leftover cards.

Test Cases
Input
Output
Expected