#104Easy
Diagonal sums
Time: 1 s · Memory: 256 MB
- Matrices
Statement
You are given an square matrix. Find the sum of the main diagonal (from the top-left to the bottom-right corner) and of the anti-diagonal (from the top-right to the bottom-left corner).
Input format
The first line contains (). Each of the next lines contains integers ().
Output format
A single line with two numbers: the main diagonal sum, then the anti-diagonal sum.
Examples
Input
3 1 2 3 4 5 6 7 8 9
Output
15 15
Input
2 1 2 3 4
Output
5 5
Note
On the main diagonal , on the anti-diagonal (counting from ). Two nested loops are not needed — one loop is enough. In the first example: and . Sums reach — long long.
