F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Sum

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2074    Accepted Submission(s): 1080


Problem Description
There is a number sequence ${A}_{1},{A}_{2}....{A}_{n}$,you can select a interval [l,r] or not,all the numbers ${A}_{i}(l \leq i \leq r)$ will become $f({A}_{i})$.$f(x)=(1890x+143) mod 10007$.After that,the sum of n numbers should be as much as possible.What is the maximum sum?
 

Input
There are multiple test cases.
First line of each case contains a single integer n.$(1\leq n\leq {10}^{5})$
Next line contains n integers ${A}_{1},{A}_{2}....{A}_{n}$.$(0\leq {A}_{i}\leq {10}^{4})$
It's guaranteed that $\sum n\leq {10}^{6}$.
 

Output
For each test case,output the answer in a line.
 

Sample Input
2 10000 9999 5 1 9999 1 9999 1
 

Sample Output
19999 22033
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-27 08:41:56, Gzip enabled