jp morgan oa question

An e - commerce company specializes in cards with sports
figures on them . Each sport has different categories of
cards . For instance , there might be more desirable cards
with the most popular sports personalities , others with
small pieces of a player’s jersey attached , and so on . They
have a number of each category of card and want to
make some number of packets greater than 1 that each
contain equal numbers of each type of card . To do this ,
they will add more cards of each type until each type can
be divided equally among some number of packets .
Determine the minimum number of additional cards
needed to create a number of packets with equal type
distribution .
Function description: int cardPackets(vector cardTypes)
Input=[3,8,7,6,4 ]

Please help me to write c++ code for this