LogiQuest

159. Sum of Squares 1..N

EasyFormula

Print 1² + 2² + … + n² modulo 10⁹ + 7.

Input format

A single integer n.

Output format

The sum mod 10⁹ + 7.

Example 1

Input

3

Output

14

Example 2

Input

1

Output

1

Constraints

1 ≤ n ≤ 10¹⁸

Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.

Loading the MyLoginn IDE…