Further information: Plot of the novelHarry Potter spends the summer without receiving letters from his Hogwarts friends. In his room, Harry meets Dobby, a house-elf who warns him bad things will happen if he returns to Hogwarts, and reveals he intercepted his friends' letters. Harry chases him downstairs, where Dobby destroys a cake. The Dursleys lock Harry up, but Ron, Fred and George Weasley rescue him in their father's flying Ford Anglia.While buying school supplies, Harry and the Weasley family encounter Rubeus Hagrid and Hermione Granger, and they attend a book-signing by celebrity wizard Gilderoy Lockhart, who announces he will be the new Defence Against the Dark Arts teacher. Harry also encounters Draco Malfoy and his father Lucius, who slips a book in Ginny Weasley's belongings. When Harry and Ron are blocked from entering Platform Nine and Three-Quarters (later revealed to be Dobby's doing), they fly to Hogwarts in the Ford Anglia and crash into the hostile Whomping Willow. Ron's wand is damaged, and the car throws them out before driving off. They are allowed back into school but face detention.While serving detention with Lockhart, Harry hears strange voices and later finds caretaker Argus Filch's cat, Mrs. Norris, petrified, and a message written in blood announcing the "Chamber of Secrets has been opened, Enemies of the Heir, beware". Professor McGonagall explains that one of Hogwarts' founders, Salazar Slytherin, supposedly constructed a secret Chamber and placed inside it a monster that only his Heir can control, to purge the school of impure-blooded wizards and witches. More attacks occur over the course of the year. Harry and Ron suspect Malfoy is the Heir, so Hermione suggests they question him while disguised using polyjuice potion. Their makeshift laboratory is in a disused bathroom haunted by a ghost, Moaning Myrtle.When Harry communicates with a snake (something Salazar Slytherin could do) the school suspects him as the Heir. At Christmas, Harry and Ron learn that Malfoy is not the Heir, but he mentions that a girl died when the Chamber was last opened fifty years ago. Harry finds an enchanted diary, owned by a former student named Tom Riddle, which shows him a flashback to fifty years before, where Riddle accused Hagrid, then a student, of opening the Chamber. When the diary disappears and Hermione is petrified, Harry and Ron question Hagrid. Professor Dumbledore, Cornelius Fudge, and Lucius Malfoy come to take Hagrid to Azkaban, but he discreetly tells the boys to "follow the spiders". Lucius has Dumbledore suspended. In the Forbidden Forest, Harry and Ron find Aragog, a giant spider who reveals Hagrid's innocence and that the dead girl was found in a bathroom. Aragog then sets his colony of Acromantula on the boys, but the now-wild Ford Anglia saves them.A book page in Hermione's hand identifies the monster is a basilisk, a giant serpent that instantly kills those who make direct eye contact with it; the petrified victims saw it indirectly. The school staff learn that Ginny was taken into the Chamber, and convince Lockhart to save her. Harry and Ron find Lockhart, exposed as a fraud, planning to flee; knowing Myrtle was the girl the Basilisk killed, they drag him to her bathroom and find the Chamber's entrance. Once inside, Lockhart uses Ron's damaged wand against them, but it backfires, wiping his memory, and causes a cave-in.Harry enters the Chamber alone and finds Ginny unconscious and dying guarded by Tom Riddle. Harry realises Riddle is the Heir and he used the diary to manipulate Ginny and reopen the Chamber. Riddle then reveals his full name, Tom Marvolo Riddle, from which he created the anagram for his future new identity, "I am Lord Voldemort". After Harry expresses support for Dumbledore, Dumbledore's Fawkes flies in with the Sorting Hat, and Riddle summons the Basilisk. Fawkes blinds the Basilisk, and the Sorting Hat eventually produces a sword with which Harry battles and slays the Basilisk, but he is poisoned by its fangs.Harry defeats Riddle and revives Ginny by stabbing the diary with a basilisk fang. Fawkes' tears heal him, and he returns to Hogwarts with his friends and a baffled Lockhart. Dumbledore, reinstated as headmaster, praises them and orders for Hagrid's release. Dumbledore shows Harry that the sword he wielded was Godric Gryffindor's own sword, and says he is different from Voldemort because he chose Gryffindor House instead of Slytherin House. Harry accuses Lucius, Dobby's master, of putting the diary in Ginny's cauldron and tricks him into freeing Dobby. The Basilisk's victims are healed, Hermione reunites with Harry and Ron, and Hagrid returns., Question: Who was reinstated as headmaster?
Output: Answer: Dumbledore