What role do valence electrons play in the formation of compounds from elements?