java prefix module
```\nclass Solution {\n    public int minSubarray(int[] nums, int p) {\n        int len = nums.length;\n        long total = 0;\n        for(int num : nums)\n  
```\nclass Solution {\n    public int minSubarray(int[] nums, int p) {\n        int len = nums.length;\n        long total = 0;\n        for(int num : nums)\n            total+=num;\n        int target = (int)(total%p);\n        if(target == 0) return 0;\n        Map<Integer, Integer> map = new HashMap();\n        map.put(0, -1);\n        int min = len;\n        int cur = 0;\n        for(int i=0; i<len; i++){\n            cur = (cur+nums[i])%p;\n            int tofind = (cur-target+p)%p;\n            if(map.containsKey(tofind))\n                min = Math.min(min, i-map.get(tofind));\n            map.put(cur, i);\n        }\n        return min == len ? -1 : min;\n    }\n}
[]