The present invention provides compounds of formula (I), wherein A1, A2, Z1, Z2, Z3, R1, R2, R3, R4, R5, R6, n, p and q are as defined herein. In certain embodiments, the compounds of the invention are RORγt antagonists. In other embodiments, the compounds of the invention are useful in the treatment and/or prevention of inflammatory and autoimmune conditions.