The invention is concerned with novel nitrogen-containing heteroaryl compounds of formula (I)
wherein A
1
, A
2
,
R
1
, R
2
, R
3
, R
4
, R
5
and R
6
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 therapeutics.