Proteins have two main secondary structures: alpha helices, which are spirals formed by hydrogen bonds between amino acids, and beta pleated sheets, [ which are formed by a bend in the amino acid with alternating hydrogen bonding between amino acids.
Look at the periodic table to find the charge on atoms. Magnesium is +2 and Nitrogen is -3. Since there are two nitrogen charge 2*-3 = -6 there needs to be 3 Mg then (3*2+ = 6+) to pair with the two nitrogen. 3 Mg(+2) + 2 N(-3) = Mg3N2