Superdiagonals

The superdiagonal of a matrix mm is formed by the elements m[i][j]m[i][j] in the matrix for which the column is one position more than the row: j=i+1j = i+1 (see https://en.wikipedia.org/wiki/Diagonal#Matrices); that is, those elements lying along the diagonal just above the main diagonal. Write a program that computes the sums of the superdiagonals of several matrices.

Input

Input is a sequence of cases. Each case starts with a nonnegative integer nn, followed by a square n×nn \times n matrix of integers.

Output

The sum of the superdiagonal elements of each matrix, in the same order, each in a line of its own.

Problem information

Author: José Luis Balcázar

Generation: 2026-01-25T16:53:02.397Z

© Jutge.org, 2006–2026.
https://jutge.org