Disclosed is a novel compound having an NPY Y5 receptor antagonistic activity.A compound represented by the formula:its pharmaceutically acceptable salt or solvate thereof,whereinX is hydrogen or the like,Y is a group of the formula:Z is —NR7— or the like,R1 is hydrogen or the like,R2 and R3 are each independently hydrogen or the like,n is 0 or 1,p is 0 to 6.