We consider how accelerated expansion, whether due to inflation or dark energy, imposes strong constraints on fundamental theories obtained by compactification from higher dimensions. For theories that obey the null energy condition (NEC), we find that inflationary cosmology is impossible for a wide range of compactifications; and a dark energy phase consistent with observations is only possible if both Newtons gravitational constant and the dark energy equation-of-state vary with time. If the theory violates the NEC, inflation and dark energy are only possible if the NEC-violating elements are inhomogeneously distributed in thecompact dimensions and vary with time in precise synchrony with the matter and energy density in the non-compact dimensions. Although our proofs are derived assuming general relativity applies in both four and higher dimensions and certain forms of metrics, we argue that similar constraints must apply for more general compactifications.