Simple Java Solution
\nclass Solution {\n    public long maxMatrixSum(int[][] matrix) {\n        int count=0;\n        int min=1000000;\n        long sum=0;\n        int l=0;\n     
```\nclass Solution {\n    public long maxMatrixSum(int[][] matrix) {\n        int count=0;\n        int min=1000000;\n        long sum=0;\n        int l=0;\n        for(int i=0;i<matrix.length;i++)\n        {\n            for(int j=0;j<matrix[i].length;j++)\n            {\n                sum=sum+Math.abs(matrix[i][j]);\n                int p=Math.abs(matrix[i][j]);\n                    if(p<min)\n                    {\n                        min=p;\n                    }\n                if(matrix[i][j]<0)\n                {\n                    count++;\n                    \n                    if((i+1)<matrix.length)\n                    {\n                        if(matrix[i+1][j]==0)\n                        {\n                            l++;\n                        }\n                    }\n                     if(j+1<matrix[i].length)\n                        {\n                            if(matrix[i][j+1]==0)\n                            {\n                                l++;\n                            }\n                        }\n                   if(j-1>=0)\n                    {\n                        if(matrix[i][j-1]==0)\n                            {\n                                l++;\n                            }\n                    }\n                    if(i-1>=0)\n                    {\n                        if(matrix[i-1][j]==0)\n                            {\n                                l++;\n                            }\n                    }\n                }\n            }\n        }\n        if(count%2!=0)\n        {\n            if(l==0)\n            {              \n              sum=sum-(2*min);\n            }\n        }\n        \n        return sum;\n        \n    }\n}\n```
[]