The present invention provides a compound having an MAGL inhibitory action, which is expected to be useful as an agent for the prophylaxis or treatment of neurodegenerative diseases (e.g., Alzheimer's disease, Parkinson's disease, Huntington's disease, amyotrophic lateral sclerosis, traumatic brain injury, glaucoma, multiple sclerosis etc.), anxiety disorder, pains (e.g., inflammatory pain, cancerous pain, neurogenic pain etc.), epilepsy, depression and the like.The present invention relates a compound represented by the formula (I):wherein each symbol is as described in the specification,or a salt thereof.