function main(input) { let [N] = getIntegers(input, " "); let [K] = getIntegers(input, " "); let prime = primeList(N, K); let hash = hashList(prime); let idx = solve(hash); console.log(prime[idx]); } function solve(L) { let i=0, j=0, max=0, maxI=0; let LL = []; while(j < L.length) { let idx = LL.indexOf(L[j], i); if(idx >= 0) i=idx+1; LL.push(L[j]); j++; if(max <= j-i) { max = j-i; maxI = i; } } return maxI; } function hashList(L) { let list = []; for(let i=0; i 1) { sum = 0; for(let j=0; j= N) out.push(String(i)); } return out; } //-- functions --------------------------------------------------------------- function getIntegers(l, s) {return s === undefined ? l.map(x=>Number(x)) : l.shift().split(s).map(x=>Number(x))} main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));