#C13506. Matrix Diagonal Difference

    ID: 43052 Type: Default 1000ms 256MiB

Matrix Diagonal Difference

Matrix Diagonal Difference

Given an \( n \times n \) matrix, compute the absolute difference between the sums of its two diagonals.

The main diagonal runs from the top left to the bottom right of the matrix, and the secondary diagonal runs from the top right to the bottom left. Formally, if \( A \) is an \( n \times n \) matrix, the sums of the diagonals are given by:

\( \text{Main} = \sum_{i=0}^{n-1} A_{i,i} \) and \( \text{Secondary} = \sum_{i=0}^{n-1} A_{i,n-1-i} \).

Your task is to output \( |\text{Main} - \text{Secondary}| \), the absolute difference between these two sums.

inputFormat

The first line contains an integer ( n ) denoting the size of the matrix. The following ( n ) lines each contain ( n ) space-separated integers representing the rows of the matrix.

outputFormat

Output a single integer, the absolute difference between the sum of the main diagonal and the sum of the secondary diagonal.## sample

3
5 3 8
4 2 6
7 1 9
1