Middlemarch is written as a third-person narrative, centering on the lives of the residents of Middlemarch, a fictitious Midlands town, from 1829 onwards   the years preceding the 1832 Reform Act. The narrative is variably considered to consist of three or four plots of unequal emphasis: the life of Dorothea Brooke; the career of Tertius Lydgate; the courtship of Mary Garth by Fred Vincy; and the disgrace of Bulstrode. The two main plots are those of Dorothea and Lydgate.  Each plot happens concurrently, although Bulstrode's is centred in the later chapters.
Dorothea Brooke appears set for a comfortable and idle life as the wife of neighbouring landowner Sir James Chettam, but to the dismay of her sister Celia and her uncle Mr Brooke, she marries The Reverend Edward Casaubon. Expecting fulfilment by sharing in his intellectual life, Dorothea discovers his animosity towards her ambitions during an unhappy honeymoon in Rome. Realising his great project is doomed to failure, her feelings change to pity. Dorothea forms a warm friendship with a young cousin of Casaubon's, Will Ladislaw, but her husband's antipathy towards him is clear and he is forbidden to visit. In poor health, Casaubon attempts to extract from Dorothea a promise that, should he die, she will "avoid doing what I should deprecate, and apply yourself to do what I should desire." He dies before she is able to reply, and she later learns of a provision to his will that, if she marries Ladislaw, she will lose her inheritance.
The young doctor Tertius Lydgate arrives in Middlemarch. Through his voluntary hospital work he meets the town's financier, Mr. Bulstrode, and through him Bulstrode's niece, the mayor's beautiful daughter Rosamond Vincy; Rosamond is attracted to Lydgate, particularly by what she believes to be his aristocratic connections. They marry, and in Lydgate's efforts to please Rosamond is soon deeply in debt and forced to seek help from Bulstrode. He is partly sustained through this by his friendship with Camden Farebrother.
Meanwhile, Rosamond's brother, Fred, is reluctantly destined for the Church. He is in love with his childhood sweetheart, Mary Garth, who will not accept him until he abandons the Church and settles on a more suitable career. At one time Fred had been bequeathed a considerable fortune by Mr Featherstone, but Featherstone later rescinded this will. However, Featherstone, on his deathbed, begs Mary to destroy this second will. Mary refuses and begs Featherstone to wait until the morning when a new legal will can be drawn up, but he dies before being able to. In debt, Fred is forced to take out a loan guaranteed by Mary's father, Caleb Garth. Then, when Fred cannot pay the loan, Caleb Garth's finances become compromised. This humiliation shocks Fred into reassessing his life, and he resolves to train as a land agent under the forgiving Caleb.
John Raffles, who knows of Bulstrode's shady past, appears in Middlemarch with the intent to blackmail him. In his youth, the church-going Bulstrode engaged in questionable financial dealings, and his fortune is founded on a marriage to a much older, wealthy widow. Bulstrode's terror of public exposure as a hypocrite leads him to hasten the death of the mortally-sick Raffles, though word has already spread. Bulstrode's disgrace engulfs Lydgate, as knowledge of the financier's loan to the doctor becomes known, and he is assumed to be complicit with Bulstrode. Only Dorothea and Farebrother maintain faith in him, but nonetheless Lydgate and Rosamond are encouraged by the general opprobrium to leave Middlemarch. The disgraced and reviled Bulstrode's only consolation is that his wife stands by him as he too faces exile.
The peculiar nature of Casaubon's will leads to suspicion that Ladislaw and Dorothea are lovers, creating an awkwardness between the two. Ladislaw is secretly in love with Dorothea, but keeps that to himself, having no desire to involve her in scandal or to cause her disinheritance. He remains in Middlemarch, working as a newspaper editor for Mr Brooke; when Brooke's election campaign collapses, he decides to leave the town and visits Dorothea to make his farewell. But Dorothea has also fallen in love with Ladislaw, whom she had previously seen only as her husband's unfortunate relative. However, the peculiar nature of Casaubon's will led her to begin to see him in a new light. Renouncing Casaubon's fortune, she shocks her family again by announcing that she will marry Ladislaw. At the same time, Fred, who has been successful in his career, marries Mary.
The "Finale" details the eventual fortunes of the main characters. Fred and Mary marry and live contently with their three sons. Lydgate operates a practice outside of Middlemarch but never finds fulfilment and dies aged fifty; leaving Rosamond and four children. After he dies, Rosamond marries a wealthy physician. Ladislaw engages in public reform and Dorothea proves to be contented as a wife and mother to their two children; their son inherits Arthur Brooke's estate.
Output: How many sons do fred and Mary have?