#include <fstream>
using namespace std;

int main(){
  long long n, a[500][500],col,row;
  ifstream fi;
  fi.open("MATRANVUONG.INP");
  fi>>n;
  for (row=0;row<n;row++){
    for (col=0;col<n;col++){fi>>a[row][col];}
  }
  fi.close();
  long long ansa=0,ansb=0,ansc=0,ansd=0,anse=0,ansf=0;
  ofstream fo;
  fo.open("MATRANVUONG.OUT");
  col=0;row=0;
  for (row=0;row<n;row++){ansa=ansa+a[row][col];
     if (row>0){ansc=ansc+a[row-1][col]+a[row][col-1];}
     col++;
  }
  col=0;
  for (row=n-1;row>=0;row--){ansb=ansb+a[row][col];
     if (row<n-1){ansd=ansd+a[row+1][col]+a[row][col-1];}
     col++;
  }
  long long z=0;
  fo<<ansa<<endl<<ansb<<endl<<ansc<<endl<<ansd<<endl;
  for (row=0;row<n-1;row++){col=z+1;
    for (col;col<n;col++){anse=anse+a[row][col];}
    z++;
  }
  z=0;
  fo<<anse<<endl;
  for (row=n-1;row>0;row--){col=z+1;
  for (col;col<n;col++){ansf=ansf+a[row][col];}
  z++;
  }
  fo<<ansf;
}
