The invention relates to new 4-(piperazin-1-yl)-2-(trifluoromethyl)-1H-indoles and 4-(piperazin-1-yl)-2-(trifluoromethyl)-1H-benzimidazoles represented by formula (I), wherein all symbols and variables are as defined in the description. The compounds can find use in a method of prevention and/or treatment of diseases selected from the group consisting of Alzheimer's disease, Parkinson's disease, Levy body dementia, dementia-related psychosis, schizophrenia, delusional syndromes and other psychotic conditions related and not related to taking psychoactive substances, depression, anxiety disorders of various aetiology, sleep disorders of various aetiology.