import * as fs from 'fs' const main = () => { const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n') const [n] = input[0].split(' ').map((x: string): number => +x) const d = input[1].split(' ').map((x: string): number => +x) const [x, y] = input[2].split(' ').map((x: string) => +x) const targetDistance = Math.abs(x) + Math.abs(y) let acc = 0 for (let i = 0, len = n; i < len; i++) { if (d[i] === targetDistance) { return console.log(1) } if (acc === targetDistance) { return console.log(2) } acc += d[i] } return console.log(-1) } main()