The present invention provides a compound useful as an agent for the prophylaxis or treatment of neurodegenerative disease and the like, or a salt thereof. The present invention relates to a compound represented by the formula wherein each symbol is as defined in the specification, or a salt thereof.