JavaScript – Algorithm [closed]

I need to write an algorithm that will loop through an array of numbers and check them against a value to distribute a set of numbers to x, y, z making sure in the end the total the sum of x,y and z is the same is total.

//If the total which is 909 is divided by 3, then 303 is evenly distributed to x, y and z. However, 303 cannot be distributed evenly since the amount that needs to be distributed is based on each number in the unique_set.
//Looping through the unique_set array, I need to check each number against the total (909) and check how many times that number can be used to ensure the total for x, y and z is as close as possible. Please see example below: 
//x=317 (50 + 167 + 50 + 50)
//y=292 (167 + 75 +25 + 25)
//z=300 (50 + 25 + 50 + 25 + 75 + 50 + 25)
//x + y + z = 909//which is  the total

const arr_list  = [50,50,25,167,167,50,25,50,75,75,25,50,25,50,25]

const unique_set = [50,25,167,75]//unique set after removing duplicates from arr_list

let total = 0 //total is 909 after looping through arr_list
let x = 0;
let y = 0;
let z = 0;

for(let i of arr){
 total += i
}