#include <fstream>
using namespace std;
int main ()
{
	ifstream f("matranvuong.inp");
    int n,tongc=0,tongp=0,tongsc=0,tongsp=0,tongtc=0,tongdp=0;
    int i,j,a[10][10];
    f>>n;
     for (i=1;i<=n;i++)
    {
        for (j=1;j<=n;j++)
        f>>a[i][j];
    }
    f.close();
    ofstream g("matranvuong.out");
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=n;j++)
        {
        if (i==j)
        tongc=tongc+a[i][j];
        if (i+j==n+1)
        tongp=tongp+a[i][j];
        if (i-j==1&j>1||j-i==1&i>1)
        tongsc=tongsc+a[i][j];
        if (i+j==n||i+j==n+2)
        tongsp=tongsp+a[i][j];
        if (i>j)
        tongtc=tongtc+a[i][j];
        if (i+j>n+1)
        tongdp=tongdp+a[i][j];
    }
	}
    g<<tongc<<endl<<tongp<<endl;
	g<<tongsc<<endl<<tongsp<<endl;
	g<<tongtc<<endl<<tongdp;
    g.close();
}
