function flatten(input, max) {
    return input.reduce((prev, current, index) => {
        for (let i = index + 1; i < max.length; i++) {
            current *= max[i];
        }
        return prev + current;
    },0);
}
@param {number[]} input 
@param {number[]} max 
@returns