The correct folrmula of Q by using Born-Haber cycle for the preparation of MgBr2(s) will be:
S = heat of sublimation of Mg(s)
I = ionisation energy of Mg(g)
D = dissociation energy of Br2(g)
-E = electron affinity of Br(g)
-U = lattice energy of MgBr2(s)
Q = heat of formation of MgBr2(s)