our hero Teemo attack enemy Ashe poison attack when Teemo attack Ashe Ashe gets poison exactly duration second more formally attack second t mean Ashe poison inclusive time interval t t duration 1 if Teemo attack poison effect end timer reset poison effect end duration second new attackyou give nondecrease integer array timeserie timeseriesi denote Teemo attack Ashe second timeseriesi integer durationreturn total number second Ashe poison Example 1input timeserie 14 duration 2output 4explanation Teemos attack ashe follow at second 1 teemo attack Ashe poison second 1 2 at second 4 teemo attack Ashe poison second 4 5ashe poison second 1 2 4 5 4 second totalexample 2input timeserie 12 duration 2output 3explanation Teemos attack ashe follow at second 1 teemo attack Ashe poison second 1 2 at second 2 teemo attack reset poison timer Ashe poison second 2 3ashe poison second 1 2 3 3 second total Constraints1 timeSerieslength 1040 timeSeriesi duration 107timeseries sort nondecrease order