CodeLab Academy 📞 9936 6696
← List Python · Level 8: Nested loops Code · 80 points ← #734 #736 →

#735. Matrix: Sum of the main diagonal

You are given a matrix of integers. **Sum of the main diagonal**. ### Input The first line has n n, each of the next n lines has n integers (a square matrix). ### Output The answer.

Examples

Input
4 4
-7 -6 -4 2
-3 3 -2 -6
-7 -7 5 -4
-2 8 -2 -2
Output
-1
Input
5 5
1 4 8 2 -5
-4 6 -9 -4 -2
3 -7 3 -2 -1
4 -1 -1 -5 9
6 6 8 -9 -6
Output
-1

💡 You can solve it with Python, JavaScript or blocks. Read the input line by line with input(). Don't print a question (like input("Number: ")). Print exactly what the output asks for, nothing more.

🔒 You can solve the first 3 problems without an account. Sign up for free to solve this one!