#include <iostream>
using namespace std;
int main()
{
int t;
cin>>t;
const int n=t;
int a[n][n];
int b[2*n-1];
for (int i=0;i<2*n-1;i++)
b[i]=0;
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
{
cin>>a[i][j];
cout<<a[i][j]<<" ";
}
cout<<"\n";
}
for (int i=0;i<n;i++)
for (int j=0;j<n;j++)
{
b[i-j+n-1]+=a[i][j];
}
for (int i=2*n-2;i>=0;i--)
cout<<b[i]<<" ";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSAKewoJaW50IHQ7CgljaW4+PnQ7Cgljb25zdCBpbnQgbj10OwoJaW50IGFbbl1bbl07CglpbnQgYlsyKm4tMV07Cglmb3IgKGludCBpPTA7aTwyKm4tMTtpKyspCgkJYltpXT0wOwoJZm9yIChpbnQgaT0wO2k8bjtpKyspCgl7CgkJZm9yIChpbnQgaj0wO2o8bjtqKyspCgkJCXsKCQkJCWNpbj4+YVtpXVtqXTsKCQkJCWNvdXQ8PGFbaV1bal08PCIgIjsKCQkJfQoJCWNvdXQ8PCJcbiI7Cgl9Cglmb3IgKGludCBpPTA7aTxuO2krKykKCQlmb3IgKGludCBqPTA7ajxuO2orKykKCQkJewoJCQkJYltpLWorbi0xXSs9YVtpXVtqXTsKCQkJfQoJZm9yIChpbnQgaT0yKm4tMjtpPj0wO2ktLSkKCQljb3V0PDxiW2ldPDwiICI7CgkKCXJldHVybiAwOwp9