Java Solution
\nclass Solution {\n    public long minSum(int[] nums1, int[] nums2) {\n        long sumNums1 = 0;\n        long sumNums2 = 0;\n        long countZeroes1 = 0;\n
```\nclass Solution {\n    public long minSum(int[] nums1, int[] nums2) {\n        long sumNums1 = 0;\n        long sumNums2 = 0;\n        long countZeroes1 = 0;\n        long countZeroes2 = 0;\n        for (int i = 0; i < nums1.length; i++) {\n            sumNums1 = sumNums1 + nums1[i];\n            if (nums1[i] == 0) {\n                countZeroes1++;\n            }\n        }\n        for (int i = 0; i < nums2.length; i++) {\n            sumNums2 = sumNums2 + nums2[i];\n            if (nums2[i] == 0) {\n                countZeroes2++;\n            }\n        }        \n        long result = 0;\n        if (sumNums1 + countZeroes1 > sumNums2 && countZeroes2 == 0) {\n            return -1;\n        }\n        if (sumNums2 + countZeroes2 > sumNums1 && countZeroes1 == 0) {\n            return -1;\n        }        \n        if (sumNums1 + countZeroes1 > sumNums2 + countZeroes2) {\n            result = sumNums1 + countZeroes1;\n        } else {\n            result = sumNums2 + countZeroes2;\n        }\n        return result;        \n    }\n}\n```
['Java']