```
public class Solution {
public int findPoisonedDuration(int[] timeSeries, int duration) {
int length = timeSeries.length;
if(length == 0 || timeSeries == null || duration == 0) return 0;
int total = 0;
for(int i = 0; i < length -1; i++){
if((timeSeries[i+1] - timeSeries[i]) >= duration )
total += duration;
else
total += (timeSeries[i+1] - timeSeries[i]);
}
total += duration;
return total;
}
}
```