#C12061. Diagonal Difference

    ID: 41447 Type: Default 1000ms 256MiB

Diagonal Difference

Diagonal Difference

You are given a square matrix \( A \) of size \( n \times n \). Your task is to calculate the absolute difference between the sum of the main diagonal and the sum of the secondary (anti-) diagonal.

The main diagonal of a matrix \( A \) is defined as the set of elements \( A[i][i] \) for \( 0 \leq i < n \). The secondary diagonal is defined as the set of elements \( A[i][n-1-i] \) for \( 0 \leq i < n \). In mathematical terms, if \( D_1 = \sum_{i=0}^{n-1} A[i][i] \) and \( D_2 = \sum_{i=0}^{n-1} A[i][n-1-i] \), you need to compute \( |D_1 - D_2| \).

It is guaranteed that the input matrix will be a valid square matrix. Make sure your solution reads input from standard input (stdin) and writes the result to standard output (stdout).

inputFormat

The input is given in the following format:

n
row1_element1 row1_element2 ... row1_elementn
row2_element1 row2_element2 ... row2_elementn
...
rown_element1 rown_element2 ... rown_elementn

Where n is the number of rows (and columns) of the matrix and each subsequent line contains n integers representing a row of the matrix.

outputFormat

Output a single integer which is the absolute difference between the sums of the main and secondary diagonals.

## sample
3
1 2 3
4 5 6
7 8 9
0

</p>