Balancing a SAM: the cross-entropy technique