By the intervention of Arthur Balfour, I was placed in the first division, so that while in prison I was able to read and write as much as I liked, provided I did no pacifist propaganda. I found prison in many ways quite agreeable. I had no engagements, no difficult decisions to make, no fear of callers, no interruptions to my work. I read enormously; I wrote a book, Introduction to Mathematical Philosophy, a semi-popular version of The Principles of Mathematics, and began the work for Analysis of Mind.
Source: The Autobiography of Bertrand Russell, v.2, 1968, chapt.1: The First World War.
More info.; https://russell-j.com/beginner/AB21-270.HTM