#K76732. Sum of the Main Diagonal

    ID: 34708 Type: Default 1000ms 256MiB

Sum of the Main Diagonal

Sum of the Main Diagonal

You are given a square matrix of size (n \times n). Your task is to compute the sum of the main diagonal elements. The main diagonal of a matrix consists of the elements (a_{ii}) where (i = 1, 2, \ldots, n). This problem will test your ability to handle matrix input and compute simple operations on indices.

inputFormat

The input is given via standard input (stdin). The first line contains an integer (n) representing the size of the matrix. The next (n) lines each contain (n) space-separated integers representing the rows of the matrix.

outputFormat

Output a single integer, which is the sum of the elements on the main diagonal of the matrix, printed to the standard output (stdout).## sample

3
1 2 3
4 5 6
7 8 9
15