The present invention aims to provide a heterocyclic compound having an AMPA receptor potentiator effect, which is expected to be useful as an agent for the prophylaxis or treatment of depression, Alzheimer's disease, schizophrenia, attention deficit hyperactivity disorder (ADHD) and the like.The present invention relates to a compound represented by the formula (I):wherein each symbol is as described in the specification, or a salt thereof.