For example,
julia> using JuMP, HiGHS
julia> model = Model(HiGHS.Optimizer);
julia> set_silent(model)
julia> @variable(model, 0 <= x[1:3] <= 3, Int)
3-element Vector{VariableRef}:
x[1]
x[2]
x[3]
julia> @variable(model, 1 <= n <= 3, Int)
n
julia> @constraint(model, [n; x] in MOI.CountDistinct(4))
[n, x[1], x[2], x[3]] ∈ MathOptInterface.CountDistinct(4)
julia> optimize!(model)
julia> value(n), value.(x)
(2.0, [1.0, 0.0, 0.0])