There are N balls in a box. The i-th ball is labeled with a positive integer A_i.
You can interact with balls in the box by taking actions under the following rules:
For given balls, what is the maximum number of actions you can take under the above rules?
N A_1 A_2 ... A_N
Output the maximum number of actions you can take in one line.
3 4 5 6
2
First, you select and remove balls labeled with 4 and 5, respectively, and add a ball labeled with 9. Next, you select and remove balls labeled with 6 and 9, respectively, and add a ball labeled with 15. Now, the balls in the box only have odd numbers. So you cannot take any actions anymore. The number of actions you took is two, and there is no way to achieve three actions or more. Thus the maximum is two and the series of the above actions is one of the optimal ways.
4 4 2 4 2
0
You cannot take any actions in this case.