Ben tries to maximize the time he watches movies. He knows that there are
nmovies that are going to be streamed on TV during the coming several days and he knows the duration of each movie. We know that Ben can only binge-watch movies for at most 5 hours (18000 seconds) and falls asleep after that. He only counts the movies that he watched from the beginning to the very end. So, if he falls asleep halfway through, that movie is not counted.
Can you help him with the decision on when to start watching, by showing how many seconds he will be able to watch fully if he starts watching from the
The first line of the input contains the integer
nthe number of movies Ben knows are going to be streamed (1 ≤ n ≤ ). The following line contains
nintegers separated by a space, that represent the lengths of the movies in seconds .
The program should print
nintegers. The number at position
ishould represent the number of seconds Ben would be able to fully watch if he starts at the movie
8 12000 3000 9000 12000 13200 13800 3600 5400
15000 12000 9000 12000 13200 17400 9000 5400