Small zeros of quadratic forms outside a union of varieties