Matrix Trace

Matrix Trace

Easy Computer Mathematics Matrices 33 views
Explanation Complexity

Problem Statement

Given n and an n x n matrix, print its trace.

Input Format

n then n lines.

Output Format

One integer trace.

Example

2
1 2
3 4
5

Constraints

n

Input / Output Format

Input Format
n then n lines.
Output Format
One integer trace.
Constraints
n

Examples

Input:
2 1 2 3 4
Output:
5

Example Solution (Public)

Computer Mathematics
Sum diagonal elements a[i][i].

Official Solution Code

Sum diagonal elements a[i][i].
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.