  We present a compact formula for the complete tree-level S-matrix of pure
Yang-Mills and gravity theories in arbitrary spacetime dimension. The new
formula for the scattering of n particles is given by an integral over the
position of n points on a sphere restricted to satisfy a dimension-independent
set of equations. The integrand is constructed using the reduced Pfaffian of a
2n by 2n matrix that depends on momenta and polarization vectors. In its
simplest form, the gravity integrand is a reduced determinant which is the
square of the Pfaffian in the Yang-Mills integrand. Gauge invariance is
completely manifest as it follows from a simple property of the Pfaffian.
