function solution(numbers) {
const arrOne = new Array(numbers.length).fill(numbers[0]);
if (arrOne.join('') === numbers.join('')) {
return numbers.reduce((prew, curr) => prew + curr);
} else {
let elem = numbers.sort((a, b) => a - b);
let lastElem = elem[elem.length - 1] - elem[0];
elem[elem.length - 1] = lastElem;
return solution(elem);
}
}