Identical Distribution

Company: Adobe_12oct

Difficulty: medium

Problem Statement

Identical Distribution Problem Description A company that sells sports cards wants to package them so that every packet contains the exact same number of cards of each type. You are given an array cardTypes , where each element represents the current quantity of a particular card type. You must choose a number of packets k , with k > 1 , and distribute the cards evenly across those packets. For a chosen k , every card type's quantity must become a multiple of k , since each packet needs an equal share of that type. You are only allowed to add cards to a type - never remove any. Your goal is to choose the best value of k (any integer greater than 1) so that the total number of cards you need to add, across all types, is as small as possible. Report this minimum number of additions. Input Format The first line contains a single integer n , the number of card types. The second line contains n space-separated integers representing cardTypes[0..n-1] . Output Format Print a single integer