The invention relates to compounds of formula
wherein the substituents are as defined in the specification and to pharmaceutically acceptable acid addition salts thereof. The invention further relates to methods for the treatment of psychoses, pain, neurodegenerative disfunction in memory and learning, schizophrenia, dementia and other diseases in which cognitive processes are impaired, such as attention deficit disorders or Alzheimer's disease.