Rhezo and Prime Problems
Practice
3.7 (703 votes)
Approved
Data structures
Dynamic programming
Easy
Number theory
Ready
Problem
81% Success 29939 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Rhezo and his friend Vanya love problem solving. They have a problem set containing N problems, with points assigned to each. Rhezo wants to solve problems in such a way that he gets the maximum number of points. Rhezo has a weird habit of solving only prime number of consecutive problems, that is, if he solves X consecutive problems from the problem set, then X should be prime. Vanya has already solved all problems from the problem set and he wonders how much maximum points Rhezo can get. Vanya can answer this, but can you?

Input:

First line contains a single integer N, denoting the number of problems in the problem set. Next line contains N space separated integers denoting the points assigned to the problems.

Output:

Print a single integer, the maximum points Rhezo can get.

Constraints:

\(1 \le N \le 5000\)

\(1 \le \)Points of Problems\( \le 10^5\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
38 votes
Tags:
Ad-HocApprovedDynamic ProgrammingEasyOpen
Points:20
89 votes
Tags:
ApprovedBasic ProgrammingDynamic ProgrammingEasyImplementationOpen
Points:30
330 votes
Tags:
ApprovedEasyReadySorting