Lady Gaga’s percussive “Poker Face” (“P-p-p poker face, p-p-p poker face”) has the staying power to echo in your brain hours after you’ve heard it, and scientists know why. There are two reasons, actually.

Gaga’s music often incorporates two major musical elements, write the scientists behind a study in the journal Psychology of Aesthetics, Creativity and the Arts, published Wednesday.

“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,’” says Kelly Jakubowski, Ph.D., of Durham University, who’s the lead author of the study, “Dissecting an Earworm: Melodic Features and Song Popularity Predict Involuntary Musical Imagery.”

1. A Common Melodic Shape

The first crucial element of an especially catchy track, the team of European scientists reported after analyzing the earworms of 3,000 participants, is an emphasis on common melodic shapes. In particular, there’s something special about musical phrases that rise and fall. Think about the chorus on Lady Gaga’s “Bad Romance”: On the “Oh-oh-oh-oh-ohs,” the melody soars upward into higher notes, falling back downward with “Caught in a bad romance.” On a musical staff, the notes would form a little hill; in our ears, they add up to a predictable tune that’s easy to digest. A similar melodic shape, the authors write, is heard in the opening riff to Maroon 5’s annoyingly catchy “Moves Like Jagger,” suggesting that Adam Levine is an earworm lord himself — perhaps a joker in Lady Gaga’s court.

Lady Gaga is the queen of earworms, according to the scientists' findings. Jakubowski et al., 2016

2. Unusual Interval Structure

No less important, in the scientists’ recipe for earworms is the presence of what they call “unusual interval structure,” which is another way of saying the music is predictable enough to create catchy patterns but not so much that it seems boring. Often, this takes the form of “unexpected leaps or more repeated notes than you would expect to hear in the average pop song,” the scientists explain. Take, for example, Lady Gaga’s “Poker Face.” The verses largely consist of the same note repeating for several measures at a time, which makes the sudden melodic leap in the chorus seem all the more surprising.

Though the new study represents the first time that the elements of an earworm have ever been formally dissected, efforts to balance surprises and predictability in music have long been considered, most recently by A.I. researchers attempting to program algorithms to craft pop songs.

So yes, producers of the future (or now) will predict which songs are going to be global hits: “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 says. “This could help aspiring song-writers or advertisers write a jingle everyone will remember for days or months afterwards.”

But actually doing that is harder than it might seem. Understanding the element of surprise requires that the listener knows how it feels to get bored of a song.

There’s a reason the French refer to earworms as musique enttante, or “stubborn music,” and the Italians refer to them as canzone tormentone, or “tormenting songs”: Whether you love or hate Lady Gaga’s music, having the same song stuck in your head can be debilitating.

The good thing about know what makes an earworm is that you can avoid them. Monotonous, droning songs are less likely to hook onto brain, as are endlessly repetitive tracks with little or no sonic interruptions.

Gaga, though, has a knack for keeping us on our toes.