The invention is concerned with novel nitrogen-containing heteroaryl compounds of formula (I)wherein A1, A2, , R1, R2, R3, R4, R5 and R6 are as defined in the description and in the claims, as well as physiologically acceptable salts and esters thereof. These compounds inhibit PDE10A and can be used as medicaments.本發明係關於式(I)之新穎含氮雜芳基化合物其中A1、A2、、R1、R2、R3、R4、R5及R6如說明書及申請專利範圍中所定義,以及其生理學上可接受之鹽及酯。此等化合物抑制PDE10A且可用作藥物。