You are given an integer n.
A sequence is formed as follows:
1st block contains 1.2nd block contains 2 * 3.ith block is the product of the next i consecutive integers.Let F(n) be the sum of the first n blocks.
Return an integer denoting F(n) modulo 109 + 7.
Example 1:
Input: n = 3
Output: 127
Explanation:
12 * 3 = 64 * 5 * 6 = 120F(3) = 1 + 6 + 120 = 127
Example 2:
Input: n = 7
Output: 6997165
Explanation:
12 * 3 = 64 * 5 * 6 = 1207 * 8 * 9 * 10 = 504011 * 12 * 13 * 14 * 15 = 36036016 * 17 * 18 * 19 * 20 * 21 = 3907008022 * 23 * 24 * 25 * 26 * 27 * 28 = 5967561600F(7) = 6006997207 % (109 + 7) = 6997165
Constraints:
1 <= n <= 1000Loading editor...
3