Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/matritsa-diagonal-ustidagi-yigindi

Sum above the main diagonal

Easy 1000 ms 128 MB 28%
Share

A square matrix of size $n \times n$ is given. Compute the sum of all elements above the main diagonal ($j \gt i$).

The sum of the elements located above the main diagonal

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 elements above the diagonal.

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
11
Input #2
1 1
5
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.