Given A Square Matrix
Given A Square Matrix
123
456
989
The left-to-right diagonal = . The right to left diagonal = . Their absolute difference is .
Function description
Return
Input Format
The first line contains a single integer, , the number of rows and columns in the square matrix .
Constraints
Output Format
Return the absolute difference between the sums of the matrix's two diagonals as a single integer.
Sample Input
3
11 2 4
456
10 8 -12
Sample Output
15
Explanation
11
5
-12
Sum across the primary diagonal: 11 + 5 - 12 = 4
4
5
10
Sum across the secondary diagonal: 4 + 5 + 10 = 19
Difference: |4 - 19| = 15