The idea is simple. Keep a marker at the position for which you have already counted time. When you get the next time (they are conveniently sorted for you already) only count the amount of the duration which is beyond the already accounted for time line.

```
public int FindPoisonedDuration(int[] timeSeries, int duration)
{
int sum = 0;
int right = 0;
foreach (int time in timeSeries)
{
if (time > right) sum += duration;
else sum += time + duration - right;
right = time + duration;
}
return sum;
}
```