```
int findPoisonedDuration(int* a, int n, int t) {
int current = 0, next = 0, time = 0;
for(int i = 0; i < n; i++){
current = a[i];
if(next <= current){
next = current + t;
time += t;
}
else {
time += (t - (next - current));
next = current + t;
}
}
return time;
}
```