WOSS Dual Olympiad 2022 Team Round P2: Bobby's Studying Schedule

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 256M

Authors:
Problem types

After getting his integration test successfully delayed by N days, Bobby wants to create a schedule to study. He checks his calendar and realizes that on the ith day, he has ti hours available to study. However, Bobby is weird and wants to study for exactly a multiple of k hours each day, where k cannot equal 1. For example, if k=3, Bobby could only study for 3,6,9,12,,21 or 24 hours on any particular day as long as that number is less than ti. Find the most amount of hours Bobby can study given his schedule, for an optimal k value.

Constraints

1N2×105

1ti24

Input Specification

The first line will contain a single integer, N, giving the number of days Bobby has to study.

The second line will contain N space-separated integers, with the ith integer being the value ti, or the amount of study time Bobby has available on the ith day.

Output Specification

Output should consist of a single line, containing a single integer: the maximum amount of hours Bobby can study with an optimal k value.

Sample Input 1

Copy
5
5 10 15 5 6

Sample Output 1

Copy
40

Explanation of Sample 1

In this case, it is optimal to choose k=5. This means that on any given day i, Bobby must study for a number of hours that is a multiple of 5, but is less than or equal to ti. On day one, Bobby studies for 5 hours. On day two he studies for 10 hours. On day three he studies for 15 hours. On day four he studies for 5 hours. On day five he studies for 5 hours. This yields a total of 40 hours.

Sample Input 2

Copy
10
24 23 24 24 23 17 15 24 24 24

Sample Output 2

Copy
218

Comments

There are no comments at the moment.