The present invention provides a heterocyclic compoundhaving a HDAC inhibitory action, and useful for the treatmentof central nervous system diseases including neurodegenerative disease,and the like, and a medicament comprising the compound. Thepresent invention relates to a compound represented by the formula(I) wherein each symbol is as defined in the specification, or a saltthereof.