The problem of the present invention is to provide a compound having a superior RORγt inhibitory action, and useful as a prophylactic or therapeutic agent for psoriasis, inflammatory bowel disease, ulcerative colitis, Crohns disease, rheumatoid arthritis, multiple sclerosis, uveitis, asthma, ankylopoietic spondylarthritis, systemic lupus erythematosus, chronic obstructive pulmonary disease or the like. The present invention relates to a compound represented by the formula (I):[wherein each symbol is as described in the DESCRIPTION] or a salt thereof, which has an RORγt inhibitory action, and useful as a prophylactic or therapeutic agent for psoriasis, inflammatory bowel disease, ulcerative colitis, Crohns disease, rheumatoid arthritis, multiple sclerosis, uveitis, asthma, ankylopoietic spondylarthritis, systemic lupus erythematosus, chronic obstructive pulmonary disease or the like.