A truck accelerates at a rate of 1 m/s2 for 10 seconds. At that time the truck continues traveling at a constant velocity for the next 20 seconds. The truck then begins to slow down at a rate of -1 m/s2 until it comes to rest. How far did the truck travel for the whole 40 seconds? Please show the equation and substitution for this.