Adding more advanced example of using scanLeft to count duration of events