#P1664. 每日打卡心情好

每日打卡心情好

Description

Luogu’s check-in system is similar to other websites: the more consecutive days you check in, the more rewards you get each time, and the consecutive days increase by one. However, on other websites, if you miss a day, your consecutive days reset to zero. Unlike other websites, Luogu is more user-friendly: if you miss multiple days, your consecutive days only decrease, and the fewer the missed days, the fewer days are deducted. The rule is to reduce by 2n12^{n-1} days, where nn is the number of consecutively missed days. The streak is settled at the next check-in, and the streak will not go below 00. In other words, if you check in every other day, the streak will remain unchanged.

When the streak reaches the following lengths, different activity point rewards are given:

11 day: reward 11 (A journey of a thousand miles begins with a single step).

33 days: reward 22 (You’ve kept it up for 33 days, keep going!).

77 days: reward 33 (The weekly cycle).

3030 days: reward 44 (From full moon to crescent, habits are formed).

120120 days: reward 55 (You’ve persisted for four months!).

365365 days: reward 66 (You kept it up for all four seasons! Not easy!).

Xiao A registered a Luogu account NN days ago. Although he vowed to check in every day, he found it hard to keep. Now that we know his check-in record for NN days, Xiao A wants to know how many activity points he can obtain from check-ins in NN days.

Input Format

The first line contains an integer NN.

The next NN lines each contain an integer 11 or 00, indicating whether he checked in on that day.

Output Format

Output a single integer, the total activity points obtained.

12
1
1
1
1
1
0
0
0
1
0
1
1
12

Hint

Day 11: 11 // Start checking in! Gain 11 activity point, total 11, streak 11 day.

Day 22: 11 // Gain 11 activity point, total 22, streak 22 days.

Day 33: 11 // Gain 22 activity points, total 44, streak 33 days.

Day 44: 11 // Gain 22 activity points, total 66, streak 44 days.

Day 55: 11 // Gain 22 activity points, total 88, streak 55 days.

Day 66: 00 // Going to Mars, no internet, had to miss a check-in.

Day 77: 00.

Day 88: 00.

Day 99: 11 // I’m back, but unfortunately the streak became 54=15-4=1 day... TQT... Gain 11 activity point, total 99, streak 22 days.

Day 1010: 00 // Ah, too many things to do, forgot it.

Day 1111: 11 // Streak became 21=12-1=1 day. Gain 11 activity point, total 1010, streak 22 days.

Day 1212: 11 // Gain 22 activity points, total 1212, streak 33 days.

Xiao A: How about making an automatic check-in machine?

kkksc03: That does not comply with Luogu’s rules!

Constraints: 1N1031 \leq N \leq 10^3.

Translated by ChatGPT 5