In this paper we establish an integral formula for compact hypersurfaces in non-flat space forms, and apply it to derive some interesting applications. In particular, we obtain a characterization of geodesic spheres in terms of a relationship between the scalar curvature of the hypersurface and the size of its Gauss map image. We also derive an inequality involving the average scalar curvature of the hypersurface and the radius of a geodesic ball in the ambient space containing the hypersurface, characterizing the geodesic spheres as those for which equality holds.