We extend the classical Ambarzumyan's theorem for the Sturm-Liouville equation (which is concerned only with Neumann boundary conditions) to the general boundary conditions, by imposing an additional condition on the potential function. Our result supplements the Pöschel-Trubowitz inverse spectral theory. We also have parallel results for vectorial Sturm-Liouville systems.