Java solution. O(n)
\nclass Solution {\n    public int minOperations(int[] nums) {\n        int ans = 0;\n        for (int i = 1; i < nums.length; i++) {\n            if (nums[i] <
```\nclass Solution {\n    public int minOperations(int[] nums) {\n        int ans = 0;\n        for (int i = 1; i < nums.length; i++) {\n            if (nums[i] <= nums[i - 1]) {\n                ans += nums[i - 1] + 1 - nums[i];\n                nums[i] = nums[i - 1] + 1;\n            }\n        }\n        return ans;\n    }\n}\n```
[]