Mark off the cuts that you need to make to cut the foam to size with a permanent marker. Follow along a straight edge to draw straight lines and keep your angles at 90 degrees.
Spray both sides of a serrated knife or electric carving blade with non-stick cooking spray. This will help the knife cut smoothly through the foam rubber.
Cut along the drawn lines with a serrated knife or an electric carving knife. Work the knife back and forth slowly to avoid injury and compressing the foam, which will lead to uneven cuts.