A study in derived algebraic geometry Volume II: Deformations, Lie theory and formal geometry