You already know that, in order to find displacement we integrate the velocity function:

We do something similar to get the distance. Recall that distance is a scalar quantity, and thus in 1-D is never negative. This leads us to the formula:

In order to do this integral, we need to find the intervals over which the integrand is negative. (See graph below.) So we need to know when

And we see that the integrand is negative for the interval

So:

I get

-Dan