require 'prime'

ns = $<.map(&:to_i)[0..-2]

primes = Prime.each(ns.max).to_a

ns.each do |n|
    j = primes.size - 1
    c = 0
    (0..primes.size-1).each do |i|
        p1 = primes[i]
        j -= 1 while p1 + primes[j] > n
        break if j < i
        c += 1 if p1 + primes[j] == n
    end
    p c
end