cumsum for histogram