After he has learned how to play Nim game, Bob begins to try another stone game which seems much easier.
The game goes like this: one player starts the game with $N$ piles of stones. There is $a_i$ stones on the $i$th pile. On one turn, the player can move exactly one stone from one pile to another pile. After one turn, if there exits a number $x(x > 1)$ such that for each pile $b_i$ is the multiple of $x$ where $b_i$ is the number of stone of the this pile now), the game will stop. Now you need to help Bob to calculate the minimum turns he need to stop this boring game. You can regard that $0$ is the multiple of any positive number.