If you ever find yourself singing along to a pop song for hours on end, you know how difficult it can be to get a catchy tune out of your head.

Now, psychologists believe they have figured out exactly why certain songs tend to stick in our heads more than others. The phenomenon is called involuntary musical imagery (INMI) — more commonly known as “earworms.”

“Earworms are an extremely common phenomenon and an example of spontaneous cognition,” the study’s lead author, Kelly Jakubowski, PhD, of Durham University in the U.K., told CBS News. “Psychologists know that humans spend up to 40 percent of our days engaging in spontaneous cognition and are starting to try to understand why our brains spend so much time thinking thoughts unrelated to our present task and how such thoughts might be useful.”

Get Breaking News Delivered to Your Inbox

The research, published in the academic journal Psychology of Aesthetics, Creativity and the Art, found that earworms are usually faster tunes with a fairly generic and easy-to-remember melody. They also tend to have some additional unique characteristics that set them apart from other songs.

Prime examples of such earworms, the study found, include “Bad Romance” by Lady Gaga, “Don’t Stop Believing” by Journey, and “Can’t Get You Out Of My Head” by Kylie Minogue.

“Our findings show that you can to some extent predict which songs are going to get stuck in people’s heads based on the song’s melodic content,” Jakubowski said in a statement. “These musically sticky songs seem to have quite a fast tempo along with a common melodic shape and unusual intervals or repetitions like we can hear in the opening riff of ‘Smoke On The Water’ by Deep Purple or in the chorus of ‘Bad Romance.’”

For the study, the researchers surveyed 3,000 people about their most frequent earworm tunes. They arrived at a set of 100 songs and then compared the melodic features of those songs to 100 other tunes that had not been named but were comparable in terms of popularity and how recently they had been on music charts.

The analysis showed that those songs most likely to get stuck in people’s heads shared common “melodic contours,” mainly found in Western pop music. For example, such songs often follow the pattern where the first phrase rises in pitch and the second falls (think “Twinkle, Twinkle Little Star”). The opening riff of “Moves Like Jagger” by Maroon 5 — one of the top-named earworm tunes in the study — also follows this common contour pattern.

Additionally, earworms typically have an unusual interval structure, such as unexpected leaps or more repeated notes than you would expect to hear in an average pop song, the researchers found. Examples of this include “My Sharona” by the Knack and “In The Mood” by Glen Miller

The most frequently named earworms in study were:

“Bad Romance” by Lady Gaga “Can’t Get You Out Of My Head” by Kylie Minogue “Don’t Stop Believing” by Journey “Somebody That I Used To Know” by Gotye “Moves Like Jagger” by Maroon 5 “California Gurls” by Katy Perry “Bohemian Rhapsody” by Queen “Alejandro” by Lady Gaga “Poker Face” by Lady Gaga

Previous research has shown a person might be more prone to earworms if they are constantly exposed to music, and certain personality traits — such as obsessive-compulsive or neurotic tendencies — can make people more likely to get songs stuck in their heads.

A small 2015 study, published in the journal Consciousness and Cognition, concluded that the size and shape of one’s brain may also play a role. Specifically, researchers found that the frequency with which people were affected by earworms depended upon the thickness of several brain regions.

While there are no scientifically proven ways to rid yourself of earworms, experts have some tips.

Jakubowski recommends trying to distract yourself by thinking of or listening to a different song. If that doesn’t work, try engaging with the song, as many people report that actually listening to an earworm song all the way through can help eliminate having it stuck on a loop.

Finally, a study published last year in the Quarterly Journal of Experimental Psychology suggests a simple way to disrupt the voluntary memory recollection that gets songs stuck in your head: chew a piece of gum.