Constraint to generate an array of random numbers where a certain value is repeated fixed number of times

In reply to dave_59:

I tried the following code on edaplayground with all simulators .

class uni_con;
  rand int arr[5];
  rand int ref_arr[5];

  
  constraint c1 {
    foreach(arr[i]){
      arr[i] > 0;}
      
      arr.sum(item) with (int'(item) == 10) == 5;
    
  }

Got following error:

testbench.sv(34): randomize() failed due to conflicts between the following constraints:
# 	testbench.sv(12): c1 { (1'((arr[0] == 10) + (arr[1] == 10) + (arr[2] == 10) + (arr[3] == 10) + (arr[4] == 10)) == 5); }
# Given:
# 	bit signed [31:0] arr[0]
# 	bit signed [31:0] arr[1]
# 	bit signed [31:0] arr[2]
# 	bit signed [31:0] arr[3]
# 	bit signed [31:0] arr[4]
# ** Note: (vsim-7106) Use vsim option '-solvefailtestcase[=filename]' to generate a simplified testcase that will reproduce the failure.
# ** Warning: (vsim-7084) No solutions exist which satisfy the specified constraints; randomize() failed.

Can you please help me understand this.