The interaction of F and Cl atoms with N2 molecule at medium distances