A compound having an SSTR5 antagonist action and use of the compound as a medicament are provided. Specifically, a compound represented by the following formula: wherein each symbol is as defined herein, or a salt thereof, a medicament comprising the compound or a salt thereof, and use of the compound or a salt thereof as an agent for the prophylaxis or treatment of diabetes mellitus are provided.