The foam should go between the top frame and the glass. Foam, like the foam used for light seals is the normal replacement, but Sam Shepard recommends using moleskin, which is a product used for cushioning foot blisters, and strange though that may sound, I have to agree that it works better and lasts longer than neoprene foam, which eventually deteriorates, becomes sticky, and pulls up on the groundglass to cause the focus error.
Also, while you have the glass out, it's a good idea to clean it with warm soapy water and let it dry before putting it back together, and remember that it goes back matte side down.