The present invention provides a compound having a superior PDE10A inhibitory action and use thereof. The compound is a compound represented by the following formula (I) :wherein each symbol is as defined in the present specification, or a salt thereof.