public static void main(String[] args) {
        Watch.start();
        int lim = 1_000_000;
        boolean[] primeTable = Utils.primeTable(lim);
        List<Integer> primes = new ArrayList<>();
        for (int i = 0; i < lim; i++)
            if (primeTable[i]) primes.add(i);
        int maxLen = 0, s = 0, maxS = 0;
        for (int end = 0; s < lim; end++, s += primes.get(end - 1))
            if (primeTable[s]) {
                maxLen = end;
                maxS = s;
            }
        s = maxS - primes.get(0) + primes.get(maxLen);
        for (int start = 1, end = maxLen; s < lim; start++, end++, s += primes.get(end) - primes.get(start - 1))
            for (int newS = s, newEnd = end; newS < lim; newEnd++, newS += primes.get(newEnd))
                if (primeTable[newS] && newEnd - start > maxLen) {
                    maxLen = newEnd - start;
                    maxS = newS;
                }
        System.out.println(maxS);
        Watch.stop();
    }