primes = [2,3,5]
while num = STDIN.gets.to_i
  if num > primes.length
    test = primes[primes.length-1]+1
    while num > primes.length
      flag = true
      i = 0
      while test >= primes[i]*primes[i]
        if test%primes[i] == 0
          flag = false
          break
        end
        i += 1
      end
      if flag
        primes.push(test)
      end
      test+=1
    end
  end
  out = 0
  for i in 0.. num-1
    out += primes[i]
  end
  puts out
  p primes
end