Natural selection for collective action