```
public class Solution {
public int findPoisonedDuration(int[] t, int d) {
if(t==null) return 0;
if(t.length==1) return d;
int i=0, err=0;
while(i<t.length-1){
if(t[i+1]<t[i]+d)
err = err + t[i+1] - t[i] - d;
i++;
}
return t.length*d+err;
}
}
```