~/algor $ cat problems/matritsa-yordamchi-diagonal-yigindisi
Anti-diagonal sum
Easy
1000 ms
128 MB
28%
A square matrix of size $n \times n$ is given. Compute the sum of the elements on its anti-diagonal (secondary diagonal):
$$S = \sum_{i=1}^{n} a_{i, n - i + 1}$$
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 anti-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
2 2 1 2 3 4
Output #2
5