When we imagine the places where our favorite authors penned their greatest masterpieces, a jail cell usually doesn’t come to mind. But, whether their writers were prisoners of war or victims of bigotry, the solitude and lack of distractions have produced many a great book. From Oscar Wilde’s apologia on spiritual awakening to Thoreau’s thoughts on civil disobedience, we survey authors whose great mental escapes from incarceration resulted in some of their most insightful and profound works, after the jump.

Don Quixote by Miguel de Cervantes

Who would have guessed the model for pop culture’s idealistic, chivalrous protagonist archetype would have originated in a jail cell? Humorous and satirical, Don Quixote is considered to be the first modern European novel, and its hero the original knight in shining armor. Cervantes penned part of his magnum opus while serving time for his debt troubles in 17th-century Spain.

The Travels of Marco Polo by Rustichello da Pisa

After 24 years and almost 15,000 miles of travel, Marco Polo returned to Italy to find Venice at war with Genoa. After Genoa overtook a Venetian fleet, Polo was taken prisoner. He spent many months of his incarceration recounting his travels to fellow inmate Rustichello da Pisa, who compiled them into what we now know as The Travels of Marco Polo. The book soon spread throughout Europe, providing Westerners insight into the “exotic East.”

Civil Disobedience by Henry David Thoreau

We usually imagine Thoreau penning his transcendentalist musings somewhere near the scenic shores of Walden Pond. And we are cheating a little bit here — he wasn’t exactly a jailbird, having only spent one night in prison after refusing to pay poll tax to a government whose values he disagreed with. But his one night in jail did inspire him to write his classic essay on civil disobedience. “Under a government which imprisons any unjustly,” he wrote, “the true place for a just man is also a prison.”

Letters from Birmingham Jail by Martin Luther King Jr.

A fan of Thoreau’s essay Civil Disobedience, King was imprisoned for organizing a non-violent protest against racial segregation in Alabama. It was in jail that King penned the now historic phrase, “injustice anywhere is a threat to justice everywhere.”

Short Stories by O. Henry

Best known for the Christmas classic The Gift of the Magi, William Sydney Porter began writing his witty stories while in prison for embezzlement (it’s still not clear whether or not he was guilty). Porter would write under various pseudonyms and enlisted his friend send his work to various publishers. His most famous pen name soon became O. Henry.

De Profundis by Oscar Wilde

Known for his witty and flippant literature, Wilde’s writing while in jail was markedly more somber and self-reflective. He was imprisoned for two years of hard labor for his indecency with men, particularly Lord Alfred Douglas. While in prison, Wilde wrote a letter to Douglas articulating the regret he felt for his ethical misconduct. Published posthumously, the apologia chronicles the journey of redemption and spiritual fulfillment that Wilde experienced in confinement.

Conversations with Myself by Nelson Mandela

More intimate than his autobiography, Conversations with Myself is a scrapbook-style piece of work chronicling Mandela’s life. The book includes letters and diary entries that Mandela penned during his 27 years in prison.

Our Lady of the Flowers by Jean Genet

This largely autobiographical work was Genet’s first novel, written during his time in prison in the 1940s. The story chronicles the experiences of Divine, a recently deceased drag queen, recounting her journeys through Paris’ colorful homosexual underworld. The novel’s free, lyrical prose is said to have been an inspiration for many Beat writers.

The Enormous Room by e.e cummings

Cummings was working as an ambulance driver during World War I when French authorities arrested him for his anti-French sentiments. Imprisoned in a detention center for four months, he recorded his experiences in the autobiographical novel The Enormous Room. Filled with colorful character sketches and amusing prose, the novel gives us insight into the famous poet’s early life.

In the Belly of the Beast by Jack Abbott

In the Belly of the Beast chronicles Jack Abbott’s 25 years behind bars and hauntingly depicts what a cruel and unjust prison system can do to a man’s mental state. The book contains correspondence between Abbott and famous author Norman Mailer. Mailer, impressed with Abbott’s writing talent, helped him get parole in 1981— the same year his book was published. He was welcomed by the New York literary scene, but was sent back to prison on a murder charge six weeks after getting released. An HBO film about their relationship is currently in the works.