Java 3 lines
\n    public int findPoisonedDuration(int[] ts, int d) {\n        int res = 0, n = ts.length;\n        for (int i = n - 1; i >= 0; i--) res += Math.min(d, (i ==
```\n    public int findPoisonedDuration(int[] ts, int d) {\n        int res = 0, n = ts.length;\n        for (int i = n - 1; i >= 0; i--) res += Math.min(d, (i == n - 1 ? Integer.MAX_VALUE : ts[i + 1]) - ts[i]);\n        return res;\n    }\n```
[]