export function sumArray(array: number[] | null): number {
  if (Array.isArray(array) && array.length > 0) {
    array.sort((a, b) => a - b);
    array.shift();
    array.pop();
    return array.reduce((acc, currentValue) => acc + currentValue, 0)
  }
  return 0;
}

console.log(sumArray([6, 2, 1, 8, 10]), 16);
console.log(sumArray([6, 0, 1, 10, 10]), 17)
console.log('slice(1, -1): [ 6, 0, 1, 10, 10 ]', [6, 0, 1, 10, 10].slice(1, -1))
