#K78002. Primary Diagonal Sum

    ID: 34989 Type: Default 1000ms 256MiB

Primary Diagonal Sum

Primary Diagonal Sum

You are given a square matrix of size \(N \times N\). Your task is to compute the sum of the elements on the primary diagonal. The primary diagonal of a matrix consists of elements \(A[i][i]\) for \(0 \leq i < N\).

Example:

Input:
3
1 2 3
4 5 6
7 8 9

Output: 15

</p>

Compute \(\sum_{i=0}^{N-1} A[i][i]\) and print the result.

inputFormat

The input is given via standard input (stdin) in the following format:

  • The first line contains an integer \(N\), the size of the matrix.
  • The next \(N\) lines each contain \(N\) space-separated integers representing the rows of the matrix.

outputFormat

Output the sum of the primary diagonal elements to standard output (stdout) as a single integer.

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