~/algor $ cat problems/matritsa-bosh-diagonal-yigindisi
Main diagonal sum
Easy
1000 ms
128 MB
27%
A square matrix of size $n \times n$ is given. Compute the sum of the elements on its main diagonal:
$$S = \sum_{i=1}^{n} a_{i,i}$$
Input
The first line contains two equal positive integers $n$ and $n$. Each of the next $n$ lines contains $n$ integers.
Output
One integer — the sum of the main diagonal elements.
Note
$1 \le n \le 200$
$-1000 \le a_{i,j} \le 1000$
Examples
Input #1
3 3 1 2 3 4 5 6 7 8 9
Output #1
15
Input #2
1 1 -4
Output #2
-4