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