Taming the Herd

Given a log of N counter readings, find for each possible number of breakouts the minimum number of entries that disagree with some valid breakout sequence that starts with a breakout on day 1.

Medium6Dynamic programmingImplementationPrefix sumBrute forceNo attempts yetTime limit2sMemory limit512 MB

Problem

Early one morning, Farmer John woke up to the sound of splintering wood. The cows were breaking out of the barn again.

Farmer John had had enough of the morning breakouts, so he nailed a counter to the barn wall. The counter shows how many days have passed since the last breakout. If a breakout happens in the morning, the counter reads 00 that day. If the most recent breakout was 33 days ago, the counter reads 33. Farmer John wrote the counter down every single day.

The year is over and Farmer John wants to settle accounts with the cows, but something about his log looks wrong. He suspects the cows tampered with it. The one thing he is sure of is that he started the log on a day when a breakout happened.

For each possible number of breakouts since the log began, find the smallest number of log entries that must have been tampered with.

Input

The first line contains one integer NN (1N1001 \leq N \leq 100), the number of days Farmer John recorded.

The second line contains NN space separated integers. If the cows did not tamper with the entry for day ii, the counter on that day read aia_i (0ai1000 \leq a_i \leq 100).

Output

Print NN lines. The iith line contains the minimum, taken over every breakout sequence with exactly ii breakouts, of the number of log entries that disagree with that sequence.

Hint

Take the six day log 1 1 2 0 0 1.

With one breakout the correct log is 0 1 2 3 4 5, which disagrees with the given log in 4 entries. With two breakouts the correct log can be 0 1 2 3 0 1, which disagrees in 2 entries, and the breakouts fall on day 1 and day 5. With three breakouts the correct log can be 0 1 2 0 0 1, which disagrees in 1 entry, and the breakouts fall on day 1, day 4 and day 5. Larger counts work the same way.