#K49927. Difference Matrix Sum

    ID: 28751 Type: Default 1000ms 256MiB

Difference Matrix Sum

Difference Matrix Sum

You are given a positive integer N. Your task is to compute the sum of all elements in an N x N matrix where the element at the intersection of the i-th row and j-th column is defined as \(|i - j|\) (with 0-based indices). This problem tests your ability to implement algorithms and correctly handle basic arithmetic operations.

Problem Details:

  • The matrix is defined as: \(A[i][j] = |i - j|\) for all \(0 \leq i, j < N\).
  • You need to compute the total sum of all the elements in this matrix.

Example:

Input: 3
Output: 8

Explanation: For N = 3, the matrix is: [ [0, 1, 2], [1, 0, 1], [2, 1, 0] ] The sum is 0+1+2+1+0+1+2+1+0 = 8.

</p>

inputFormat

The input consists of a single integer N (1 \leq N \leq 10^4 or based on constraints) provided via standard input.

outputFormat

Output a single integer, which is the sum of all elements in the difference matrix, printed to standard output.

## sample
3
8