#include <iostream>
#include <fstream>
using namespace std;
long int n,i,j,a[1000][1000],tong=0,tongp=0,satp=0,satc=0,sata=0,satb=0;
int main()
{
    fstream fi,fo;
    fi.open("matranvuong.inp",ios::in);
    fo.open("matranvuong.out",ios::out);
    fi>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {fi>>a[i][j];
        if(i==j)
        {tong=tong+a[i][j];}
        if(i+j==n+1)
        {tongp=tongp+a[i][j];}
        if(j==i-1 || i==j-1)
        {satc=satc+a[i][j];}
        if(i+j==n || i+j==n+2)
        {satp=satp+a[i][j];}
        if(i<j )
        {sata=sata+a[i][j];}
        if(i>j )
        {satb=satb+a[i][j];}
        }

    }
    fo<<tong<<endl<<tongp<<endl<<satp<<endl<<satc<<endl<<sata<<endl<<satb;

    return 0;
}
