This phenomenon is known as savant syndrome. This term refers to a person who possesses some ability above average, despite suffering from some significant intellectual disability. This affectation is common among people who have a neurodevelopmental disorder such as autism spectrum disorders, and the skills that stand out are those related to numerical analysis, memory and artistic or musical skills.
I hope my answer can help you.