To get P , S , MR , and MC
for ( int i = 0 ; i < mat . GetLength ( 0 ) ; i ++ ) { for ( int j = 0 ; j < mat . GetLength ( 1 ) ; j ++ ) { if ( i == j ) P . Add ( mat [ i , j ] ) ; if ( i + j == mat . GetLength ( 0 ) - 1 ) S . Add ( mat [ i , j ] ) ; if ( i == Math . Floor ( ( mat . GetLength ( 0 ) - 1 ) / 2.0 ) ) MR . Add ( mat [ i , j ] ) ; if ( j == Math . Floor ( ( mat . GetLength ( 0 ) - 1 ) / 2.0 ) ) MC . Add ( mat [ i , j ] ) ; } } S . Reverse ( ) ;