Formal charge $=$ total number of valence electrons
- total number of non-bonding electrons $-\frac{1}{2} \times$ total number of bonding electrons
As for structure
For Ist and 3rd nitrogen atom
Formal charge $=5-4-\frac{1}{2} \times 4=-1$
For middle nitrogen atom
Formal charge $=5-0-\frac{1}{2} \times 8=+1$