#B3962. Carousel Rides
Carousel Rides
Carousel Rides
Little Ming loves going to amusement parks, especially riding carousels. Each ride on the carousel costs \(8\) yuan. Every visit to the park may involve riding the carousel multiple times.
Every day, his mother gives him an allowance of 1 yuan. Initially, on day 0, he has no money. However, once the money in his hand reaches \(50\) yuan, his mother will no longer give him any allowance.
The plan is to take Little Ming to the amusement park \(n\) times on days \(a_1, a_2, \cdots, a_n\). Note that multiple visits can occur on the same day. On each visit, he uses all the money he currently has to ride the carousel repeatedly until his remaining money is less than \(8\) yuan.
Please determine the total number of carousel rides he will have taken after all \(n\) visits.
inputFormat
The first line contains a positive integer \(n\) indicating the number of amusement park visits. The second line contains \(n\) non-negative integers \(a_1, a_2, \cdots, a_n\) (separated by spaces), where \(a_i\) represents the day on which the \(i\)th visit occurs. Note that visits on the same day are allowed.
outputFormat
Output a single integer representing the total number of carousel rides after all visits.
sample
3
0 1 1
0
</p>