```
public class Solution {
public int findPoisonedDuration(int[] timeSeries, int duration) {
int len = timeSeries.length;
if(len==0){
return 0;
}
int sum=0;
for(int i=0;i<len-1;i++){
int gap = timeSeries[i+1]-timeSeries[i];
sum += Math.min(gap,duration);
}
sum +=duration;
return sum;
}
}
```