Described herein is a technique capable of forming a film whose characteristics are uniform by discharging a residual component from a plurality of grooves before supplying a process gas. According to one aspect thereof, there is provided a substrate processing apparatus including: (a) loading a substrate on which a plurality of grooves are provided into a process chamber, wherein a residue is adhered to the plurality of the grooves; (b) desorbing the residue from the plurality of the grooves by heating the substrate; and (c) discharging the residue from the plurality of the grooves to a process space of the process chamber after (b) is performed by heating a surface of the substrate to a temperature higher than a temperature of the substrate in (b).