oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

ferrari Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

ferrari.html

Problem Description

Rar the Cat has bought a new Ferrari and wants to race it down a very long track. However, the track has N traffic lights in his way.

Rar can only race on the track when all traffic lights turn green at the same time. Assume he takes negligible time to traverse the entire road in his very fast Ferrari.

The ith traffic light on the road stays red for Ti minutes, and then turns green for one minute, before turning red again in a periodic fashion.

When Rar arrives at the racing track, all the lights (except those with Ti = 0) have just turned from green to red. Help Rar determine how long he would have to wait to race, in minutes. Since this time may be very long, output it modulo 109 + 7.

Input

The first line of input will contain one integer, N.

The second line of input will contain N integers, with the ith integer being Ti.

Output

The output should contain one integer, the time, in minutes, Rar would have to wait, modulo 109 + 7.

Limits

Subtask 1 (23%): 1 ≤ N ≤ 100. Rar would not have to wait more than 105 minutes.

Subtask 2 (18%): 1 ≤ N ≤ 2 000, 1 ≤ Ti ≤ 2 000.

Subtask 3 (35%): 1 ≤ N ≤ 10 000. 1 ≤ Ti ≤ 105.

Subtask 4 (24%): 1 ≤ N ≤ 50 000. 1 ≤ Ti ≤ 109.

Subtask 5 (0%): Sample Testcases

Sample Testcase 1

Input

3
1 1 1

Output

1

Sample Testcase 1

Input

3
1 2 3

Output

11

Tags

Math

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
123223s64MBMinimum
218223s64MBMinimum
335623s64MBMinimum
424823s64MBMinimum
5023s64MBMinimum

Judge Compile Command

g++-8 ans.cpp -o ferrari -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.