In a 1988 interview with Rolling Stone, the late actor and comedian Robin Williams opened up about finding gratitude for life’s hardships, including his recent divorce and the death of his father. After one of the most difficult years of his life, Williams said, he took to heart a friend’s advice about cultivating a sense of thankfulness. 

“Someone said I should send out Buddhist thank-you cards,” he said, “since Buddhists believe that anything that challenges you makes you pull yourself together.”

With characteristic wit and insight, Williams tapped into the heart of one of the most foundational and empowering teachings of Buddhism: suffering can be our greatest source of transformation. The dharma teachings show us how to use all the stuff of life—particularly those unavoidable experiences of pain, loss, and suffering—as fodder for awakening. 

It’s easy to be grateful for life’s “10,000 joys”—but what about it’s “10,000 sorrows”? Cultivating an awareness of the gifts of adversity can help us to not only weather the difficult storms of our lives but also come out wiser and more compassionate than ever before. 

True gratitude isn’t limited to experiences of joy, love, and pleasure, as Vipassana teacher Jack Kornfield emphasizes. “In certain temples that I’ve been to, there’s actually a prayer that you make asking for difficulties,” he told me last year. “May I be given the appropriate difficulties so that my heart can truly open with compassion. Imagine asking for that.”

Kornfield went on to say that his meditation master in the jungles of Thailand would ask him, “Where have you learned more compassion?”

This idea is reflected in the saying, “No mud, no lotus.” The symbolic lotus flower blooms out of the mud; its growth is rooted in the dirt and grime. As the metaphor goes, it is from suffering that we learn compassion, from loss that we learn understanding, and from overcoming struggles that we come to discover our own strength and beauty. These struggles may just be the “appropriate difficulties” that we need in order to grow. As novelist and former heroin addict Gregory David Roberts wrote in Shantaram, “Sometimes you break your heart in the right way, if you know what I mean.” 

Related: The Good Fit: A student’s candid recollection of the intricacies of practice with one of the pioneer teachers of Zen in the West

When life presents us with challenges, we can get stuck in the mud—in our habitual reactions and patterns—or we can be present to the suffering and find compassion and strength within the discomfort, blossoming like the lotus. 

This notion of the transformative power of suffering is now being reinforced by psychological research. In the past 20 years, scientists have begun studying the phenomenon of post-traumatic growth, a term coined in the 1990s by psychologists Richard Tedeschi and Lawrence Calhoun to describe instances of individuals who experienced profound transformation as they coped with various types of trauma and adversity. This phenomenon has now been observed in more than 300 scientific studies, and research has found that up to 70 percent of trauma survivors report some positive psychological growth. 

Often, these survivors report a greater sense of meaning and a new way of seeing the world. Survivors also describe experiencing greater empathy and compassion, and many say that they develop renewed creative interests and inspiration. 

As I discuss in my new book Wired to Create: Unraveling the Mysteries of the Creative Mind (co-authored with psychologist Scott Barry Kaufman), through our suffering we can become not only more compassionate but also more authentically creative.  

One way that adversity can lead to creativity is by way of compassion. Encountering the depths of our own pain and vulnerability allows us to be with the suffering of others. As Pema Chödrön once wrote, we can only be fully present to the darkness of others when we know our own darkness—“Compassion becomes real when we recognize our shared humanity.” So much of art is an attempt to find meaning in human suffering—and when we have compassion for ourselves and others, a deeper understanding and appreciation for our shared humanity shines through our creative pursuits. 

Related: Your Brain on Neuroscience

Artistic pursuits can also themselves be a powerful way of finding meaning in the face of suffering. Art seeks to make sense of everything from life’s smallest moments of sadness to its most earthshattering tragedies. Frida Kahlo made self-portraits to express the pain of her multiple miscarriages, childhood polio, and chronic pain. Van Gogh projected his turbulent inner life onto his sweeping canvases. Anyone who listens to the Moonlight Sonata can hear Beethoven’s struggle with his inner darkness. As Ray Charles once said, “Man, you could just feel the pain this man was going through. He was very, very lonesome when he wrote that.” 

And last, art can be a vehicle for the development of compassion. In our individual and collective quest to understand the darker sides of human life, works of art that show us the truth of another’s pain and loneliness carry the power to move us deeply. 

Out of loss, there can be creative gain. Adversity can provide powerful inspiration for work that strives to make sense of the artist’s inner life and emotional state. And when a piece of art succeeds in elevating suffering in some way, the results can be breathtaking.