Problem R
Killing Chaos
In the dangerous wild west, robbers are attacking a long
train with many coaches. Chaos erupts, and the robbers realize
that the amount of chaos equals the number of passengers in the
train, rounded up to the nearest multiple of
What the robbers failed to realize, however, is that when there are multiple disjoint train segments, then the total amount of chaos is equal to the sum of the chaos of each train segment times the number of train segments!
Frantic to quench the now even worse chaos, the robbers continue blowing up every coach until all passengers are dead. Phew!
The chaos in a train segment is equal to the number
passengers in that train segment rounded up to the nearest
multiple of
Input
On the first line is a single integer
Output
A single integer, the maximum chaos that occurred during the robbery.
Sample Input 1 | Sample Output 1 |
---|---|
5 3 5 10 2 5 2 4 5 1 3 |
90 |
Sample Input 2 | Sample Output 2 |
---|---|
4 32 3 3 3 1 3 2 4 |
50 |