We’re preparing your current view and syncing the latest data.
You are given a square matrix of size n x n. Your task is to find the trace of the matrix, defined as the sum of the elements on the main diagonal (from top-left to bottom-right).
The first line contains an integer n, the size of the matrix. Each of the next n lines contains n integers, representing the rows of the matrix.
Output a single integer, the trace of the matrix.
1 ≤ n ≤ 100 -1000 ≤ matrix element ≤ 1000
Example 1
Input
3 1 2 3 4 5 6 7 8 9
Output
15
Explanation
Sum of diagonal elements: 1 + 5 + 9 = 15