#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    ifstream f1("matranvuong.inp");
    int n,dema=0,demb=0,demc=0,demd=0,deme=0,demf=0;
    int a[100][100];
    f1>>n;
    for(int row=1;row<=n;row++){
        for(int col=1;col<=n;col++){
            f1>>a[row][col];
        }
    }
    for(int row1=1;row1<=n;row1++){
        for(int col1=1;col1<=n;col1++){
            if(row1==col1){
                dema=dema+a[row1][col1];
            }
            if(row1+col1==n+1){
                demb=demb+a[row1][col1];
            }
            if(row1-col1==1 || col1-row1==1){
                demc=demc+a[row1][col1];
            }
            if(row1+col1==n || row1+col1==n+2){
                demd=demd+a[row1][col1];
            }
            if(col1-row1>0){
                deme=deme+a[row1][col1];
            }
            if(row1+col1>n+1){
                demf=demf+a[row1][col1];
            }
        }
    }
    ofstream f2("matranvuong.out");
    f2<<dema<<endl;
    f2<<demb<<endl;
    f2<<demc<<endl;
    f2<<demd<<endl;
    f2<<deme<<endl;
    f2<<demf<<endl;
    f1.close();
    f2.close();
}
