P8692 [Lanqiao Cup 2019 National Contest Group C] Counting Squares

Description

On an $N \times N$ lattice of points, choose $4$ points that form exactly the four vertices of a square. How many different ways are there? Since the result may be very large, you only need to output the remainder modulo $10^9 + 7$. ![](https://luogu.oss-cn-hangzhou.aliyuncs.com/upload/vjudge_pic/lanqiao/2022_09_30_4ab10c5eb27e3dea37d8g-09.jpg) As shown in the figure above, all these squares are valid.

Input Format

The input contains one integer $N$.

Output Format

Output one integer representing the answer.

Explanation/Hint

For all test cases, $2 \le N \le 10^6$. Lanqiao Cup 2019 National Contest Group C, Problem G. Translated by ChatGPT 5