#C13974. Prime Group Sum

    ID: 43571 Type: Default 1000ms 256MiB

Prime Group Sum

Prime Group Sum

You are given a single integer n as input. Your task is to compute the sum of the first n prime numbers after they have been grouped by the number of digits they have. More precisely, you should:

  1. Generate the first n prime numbers.
  2. Group these primes based on the number of digits (for instance, 1-digit primes, 2-digit primes, etc.).
  3. For each group, calculate the sum of the primes in that group.
  4. Output the sum of all these group sums.

Note: If n is zero, the output should be 0.

Example:

Input: 10
Output: 129

Explanation: The first 10 primes are: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29. They form the groups: Group 1 (1-digit): 2+3+5+7 = 17 Group 2 (2-digit): 11+13+17+19 = 60 Group 3 (2-digit): 23+29 = 52 Total sum: 17 + 60 + 52 = 129

</p>

inputFormat

The input is read from standard input (stdin) and consists of a single integer n, which indicates the number of prime numbers to be considered.

outputFormat

Output a single integer to standard output (stdout) which is the sum of the sums of the prime groups.

## sample
10
129