A census of very-low-mass stars and brown dwarfs in the sigma Orionis cluster