Wolfram Language (Mathematica), 73 bytes
Max[Tr/@Join[#,#,{#,Reverse@#}]&/@Join@@Partition[#2,{#,#},1,1,-∞]]&
TIO-friendly version, (削除) 81 (削除ここまで) 77 bytes
Max[Tr/@Join[#,#\:f3c7,{#,Reverse@#}]&/@Join@@Partition[#2,{#,#},1,1,Log@0]]&
How it works
Takes first N and then the matrix A as input.
Join@@Partition[#2,{#,#},1,1,-∞] finds every N by N submatrix of the matrix A, padded with -∞ where necessary to ensure that lines running out of the grid will be out of the running.
For each of those blocks we compute Tr/@Join[#,#,{#,Reverse@#}]: the trace (i.e. sum) of each row, the trace (i.e. sum) of each column, the trace (actually the trace, for the first time in the history of Mathematica code golfing) of the block, and the trace of the block reversed. # is Transpose@#.
Then we find the Max of all of these.
Wolfram Language (Mathematica), 73 bytes
Max[Tr/@Join[#,#,{#,Reverse@#}]&/@Join@@Partition[#2,{#,#},1,1,-∞]]&
TIO-friendly version, (削除) 81 (削除ここまで) 77 bytes
Max[Tr/@Join[#,#\:f3c7,{#,Reverse@#}]&/@Join@@Partition[#2,{#,#},1,1,Log@0]]&
How it works
Takes first N and then the matrix A as input.
Join@@Partition[#2,{#,#},1,1,-∞] finds every N by N submatrix of the matrix A, padded with -∞ where necessary to ensure that lines running out of the grid will be out of the running.
For each of those blocks we compute Tr/@Join[#,#,{#,Reverse@#}]: the trace (i.e. sum) of each row, the trace (i.e. sum) of each column, the trace (actually the trace, for the first time in the history of Mathematica code golfing) of the block, and the trace of the block reversed. # is Transpose@#.
Then we find the Max of all of these.
Wolfram Language (Mathematica), 73 bytes
Max[Tr/@Join[#,#,{#,Reverse@#}]&/@Join@@Partition[#2,{#,#},1,1,-∞]]&
How it works
Takes first N and then the matrix A as input.
Join@@Partition[#2,{#,#},1,1,-∞] finds every N by N submatrix of the matrix A, padded with -∞ where necessary to ensure that lines running out of the grid will be out of the running.
For each of those blocks we compute Tr/@Join[#,#,{#,Reverse@#}]: the trace (i.e. sum) of each row, the trace (i.e. sum) of each column, the trace (actually the trace, for the first time in the history of Mathematica code golfing) of the block, and the trace of the block reversed. # is Transpose@#.
Then we find the Max of all of these.
Wolfram Language (Mathematica), 73 bytes
Max[Tr/@Join[#,#,{#,Reverse@#}]&/@Join@@Partition[#2,{#,#},1,1,-∞]]&
TIO-friendly version, 81(削除) 81 (削除ここまで) 77 bytes
Max[Tr/@Join[#,Transpose@##\:f3c7,{#,Reverse@#}]&/@Join@@Partition[#2,{#,#},1,1,Log@0]]&
How it works
Takes first N and then the matrix A as input.
Join@@Partition[#2,{#,#},1,1,-∞] finds every N by N submatrix of the matrix A, padded with -∞ where necessary to ensure that lines running out of the grid will be out of the running.
For each of those blocks we compute Tr/@Join[#,#,{#,Reverse@#}]: the trace (i.e. sum) of each row, the trace (i.e. sum) of each column, the trace (actually the trace, for the first time in the history of Mathematica code golfing) of the block, and the trace of the block reversed. # is Transpose@#.
Then we find the Max of all of these.
Wolfram Language (Mathematica), 73 bytes
Max[Tr/@Join[#,#,{#,Reverse@#}]&/@Join@@Partition[#2,{#,#},1,1,-∞]]&
TIO-friendly version, 81 bytes
Max[Tr/@Join[#,Transpose@#,{#,Reverse@#}]&/@Join@@Partition[#2,{#,#},1,1,Log@0]]&
How it works
Takes first N and then the matrix A as input.
Join@@Partition[#2,{#,#},1,1,-∞] finds every N by N submatrix of the matrix A, padded with -∞ where necessary to ensure that lines running out of the grid will be out of the running.
For each of those blocks we compute Tr/@Join[#,#,{#,Reverse@#}]: the trace (i.e. sum) of each row, the trace (i.e. sum) of each column, the trace (actually the trace, for the first time in the history of Mathematica code golfing) of the block, and the trace of the block reversed. # is Transpose@#.
Then we find the Max of all of these.
Wolfram Language (Mathematica), 73 bytes
Max[Tr/@Join[#,#,{#,Reverse@#}]&/@Join@@Partition[#2,{#,#},1,1,-∞]]&
TIO-friendly version, (削除) 81 (削除ここまで) 77 bytes
Max[Tr/@Join[#,#\:f3c7,{#,Reverse@#}]&/@Join@@Partition[#2,{#,#},1,1,Log@0]]&
How it works
Takes first N and then the matrix A as input.
Join@@Partition[#2,{#,#},1,1,-∞] finds every N by N submatrix of the matrix A, padded with -∞ where necessary to ensure that lines running out of the grid will be out of the running.
For each of those blocks we compute Tr/@Join[#,#,{#,Reverse@#}]: the trace (i.e. sum) of each row, the trace (i.e. sum) of each column, the trace (actually the trace, for the first time in the history of Mathematica code golfing) of the block, and the trace of the block reversed. # is Transpose@#.
Then we find the Max of all of these.
Wolfram Language (Mathematica), 73 bytes
Max[Tr/@Join[#,#,{#,Reverse@#}]&/@Join@@Partition[#2,{#,#},1,1,-∞]]&
TIO-friendly version, 81 bytes
Max[Tr/@Join[#,Transpose@#,{#,Reverse@#}]&/@Join@@Partition[#2,{#,#},1,1,Log@0]]&
How it works
Takes first N and then the matrix A as input.
Join@@Partition[#2,{#,#},1,1,-∞] finds every N by N submatrix of the matrix A, padded with -∞ where necessary to ensure that lines running out of the grid will be out of the running.
For each of those blocks we compute Tr/@Join[#,#,{#,Reverse@#}]: the trace (i.e. sum) of each row, the trace (i.e. sum) of each column, the trace (actually the trace, for the first time in the history of Mathematica code golfing) of the block, and the trace of the block reversed. # is Transpose@#.
Then we find the Max of all of these.