406185: GYM102302 J Weird Sanchola

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Weird Sancholatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Sanchola is getting an array of integers as gift. He's weird, so he doesn't like having distinct integers in the same array and he only likes prime numbers. That's why he believes that he might need to fix the array after receiving it by turning all elements into the same prime number.

Sanchola is also very lazy and wants to do that using the minimum number of operations. In one operation Sanchola can either increase or decrease a single element of the array by one.

Given the array that he received as a gift, help Sanchola figuring out the minimum number of operations required to fix the array.

Input

The first line contains a single integer $$$N$$$ $$$(1 \leq N \leq 10^{5})$$$, indicating the length of the array.

The second line contains $$$N$$$ integers $$$a_{1}$$$, $$$a_{2}$$$, ..., $$$a_{n}$$$ $$$(1 \leq N \leq 10^{9})$$$, indicating the elements of the array $$$a$$$.

Output

In a single line output the minimum number of operations to satisfy Sanchola.

ExamplesInput
3
2 3 10
Output
8
Input
2
1 1000000000
Output
999999999
Input
4
3 5 7 11
Output
10

Source/Category

加入题单

上一题 下一题 算法标签: