Provided is a compound having an antagonistic action on an NMDA receptor containing the NR2B subunit, and is useful as a prophylactic or therapeutic agent for major depression, bipolar disorder, migraine, pain, peripheral symptoms of dementia and the like. A compound represented by the formula (I) : wherein each symbol is as described in the DESCRIPTION, (excluding N-(4-bromo-3-(1H-1,2,4-triazol-5-yl)thiophen-2-yl)-2-(imidazo[1,2-a]pyridin-5-yl)acetamide) or a salt thereof.