n = int(input())
m=[]
for i in range(n):
    m.append([int(j) for j in input().split()])
sum=0    
for i in range(n):
    for j in range(n):
        if(i==j):
            sum+=m[i][j] 
print(sum)               

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: