An Integration by Parts Formula in Sobolev Spaces