const row = require('fs').readFileSync('/dev/stdin','utf8').split('\n'); const column = row.map(e => e.split(' ').map(e => Number(e))); const sum = column[0][0] * column[0][1]; const eatBeans = column[1].reduce((acc, cur) => { return acc + cur; }); let result = -1; if(sum - eatBeans >= 0) { result = sum - eatBeans; } console.log(result);