Simple Java 0ms solution
Complexity
Time complexity:O(N)

Space complexity:O(1)
Code
# Complexity
- Time complexity:O(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int minElements(int[] nums, int limit, int goal) {
        long sum = 0 ;
        int n = nums.length;
        for(int num :nums)sum+=num;
        if(sum==goal)return 0;
        long req = Math.abs(goal - sum);
        return (req%limit ==0)? ((int) (req/limit)) : ((int) (req/limit))+1;
    }
}
```
['Java']