Calculate cumulative valuse