#include
int main()
{
int N;
scanf ("%d", &N);
int i, j, sum, A[N][N];
for ( i = 0; i < N; i ++ )
for ( j = 0; j < N; j ++ )
{
printf ("A[%d][%d]=", i, j);
scanf ("%d", & A[i][j]);
}
sum = 0;
for ( i = 0; i < N; i ++ ) sum+=A[i][i];
printf ("sum = %d",sum);
//getch();
}