$prime = {}
$p = {}
def p(i)
  unless $p[i]
    if i == 0
      $p[i] = 2
    elsif i == 1
      $p[i] = 3
    else
      j = p(i-1) + 2
      loop do
        break if is_prime(j)
        j += 2
      end
      $p[i] = j
    end
  end
  return $p[i]
end

def sum_p(n)
  sum = 0
  n.times{|i|
    sum += p(i)
  }
  return sum
end

def is_prime(n)
  unless $prime[n]
    if n < 2
      $prime[n] = false
    elsif n < 4
      $prime[n] = true
    elsif n % 2 == 0
      $prime[n] = false
    else
      i = 3
      flag = true
      while i <= Math.sqrt(n)
        if n % i == 0 then
          flag = false
          break
        end
        i += 2
      end
      $prime[n] = flag
    end
  end
  return $prime[n]
end

while n = gets.to_i
  break if n == 0
  puts sum_p(n)
end