#B4136. Sum of Squares Sequence

    ID: 11793 Type: Default 1000ms 256MiB

Sum of Squares Sequence

Sum of Squares Sequence

Little Ming has written out a sequence where the i-th term is given by \(a_i = i^2\). The sequence starting from the first term \((i=1)\) is: 1, 4, 9, 16, 25, …. Given an integer n, your task is to compute the sum of the first n terms of this sequence.

You may recall that the sum of the squares of the first n natural numbers is given by the formula:

\( S = \frac{n(n+1)(2n+1)}{6} \)

However, you can also compute the sum iteratively.

inputFormat

The input consists of a single integer n (1 \leq n \leq 10^5), which represents the number of terms from the sequence to sum.

outputFormat

Output a single integer, the sum of the first n terms of the sequence.

sample

1
1