Scala 7 liner
Code\n\nobject Solution {\n    def minSum(nums1: Array[Int], nums2: Array[Int]): Long =\n        (stat(nums1), stat(nums2)) match {\n            case ((s1, 0), 
# Code\n```\nobject Solution {\n    def minSum(nums1: Array[Int], nums2: Array[Int]): Long =\n        (stat(nums1), stat(nums2)) match {\n            case ((s1, 0), (s2, 0)) => if s1 == s2 then s1 else -1\n            case ((s1, 0), (s2, z2)) => if s2 + z2 <= s1 then s1 else -1\n            case ((s1, z1), (s2, 0)) => if s1 + z1 <= s2 then s2 else -1            \n            case ((s1, z1), (s2, z2)) => (s1 + z1) max (s2 + z2)\n        }\n\n    def stat(nums: Array[Int]): (Long, Int) = (nums.map(_.toLong).sum, nums.count(_ == 0))\n}\n```
['Scala']