Explanation:
Valence electrons is the number of electrons in the outermost shell of an atom. For the main group elements, the group number represents the number of valence electrons.
Beryllium
This belongs to the group 2 hence, it has valency of 2.
Nitrogen
This belongs to group 5, hence it has valency of 5.
Oxygen
This belongs to group 6, hence it has valency of 6.
Fluorine
This belongs to group 7, hence it has valency of 7.
Magnesium
This belongs to group 2, hence it has valency of 2.
Phosphorus
This belongs to group 5, hence it has valency of 5
Sulphur
This belongs to group 6, it has valency of 6
Chlorine
This belongs to group 7, it has valency of 7