The present invention relates to novel heteroaryl amide derivatives of formula (I)as selective inhibitors of histone deacetylase 1 and 2 (hdac1-2) to processes for their preparation, to pharmaceutical compositions comprising said compounds and to the use of said compounds for manufacturing a medicament for the treatment of pathological conditions or diseases that can improve by inhibition the activity of histone deacetylase class I, particularly HDAC1 and HDAC2, such as cancer, neurodegenerative diseases, Infectious diseases, inflammatory diseases, heart failure and cardiac hypertrophy, diabetes, polycystic kidney disease, sickle cell disease and β-thalassemia disease and to methods for the treatment of the disesases mentioned above.