The invention relates to serotonin 5-HT6 receptor antagonists—novel 2-amino-3-arylsulfonyl-6,7,8,9-tetrahydropyrazolo[1,5-a]pyrido[4,3-e]pyrimidines and substituted 2-amino-3-arylsulfonyl-5,6,7,8-tetrahydropyrazolo[1,5-a]pyrido[4,3-d]pyrimidines, drug substances and pharmaceutical compositions comprising the said drug substances as the said compounds, and also to method of prophylaxis and treatment of various diseases of central nervious system in humans and animals pathogenesis of which is associated with serotonin 5-HT6 receptors including cognitive and neurodegenerative diseases.Substituted 2-amino-3-arylsulfonyl-6,7,8,9-tetrahydropyrazolo[1,5-a]pyrido[4,3-e]pyrimidines of the general formula 1 and substituted 2-amino-3-arylsulfonyl-5,6,7,8-tetrahydropyrazolo[1,5-a]pyrido[4,3-d]pyrimidines of the general formula 2 and pharmaceutically acceptable salts and/or hydrates thereof.wherein: Ar is optionally substituted aryl or optionally substituted heteroaryl; R1 is hydrogen, optionally substituted C1-C3 alkyl, C1-C4 alkyloxycarbonyl; R2 is hydrogen, halogen or optionally substituted C1-C3 alkyl; R13 and R23 represent optionally alike: hydrogen, optionally substituted C1-C3 alkyl or R13 and R23 together with the nitrogen atom to which they are attached form an optionally substituted azaheterocycle.