Lets say you want to get more AP going 0/21/9 (The bonus mana mastery gives you 85 AP with this build, verus the offensive tree's 11, mana runes still give you a LOT more bonus AP than the AP runes do)
So, lets skip some math.
Total AP: 1116 (old total minus offensive masteries) Bonus from Zhonya's: 279 Real Total AP: 1395
2% bonus from defensive masteries: 27 2% bonus from being level 18*: 28 Total: 1450
*The way the Ardor masteries looks to work is that is gives you a bonus 2%, until level 18 which is gives you an extra 2% on that. Short Math: You get the 2%, and after that is calculated, you get a bonus 2%. This is why there is a difference of one AP.