406185: GYM102302 J Weird Sanchola
Description
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.
InputThe 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$$$.
OutputIn a single line output the minimum number of operations to satisfy Sanchola.
ExamplesInput3 2 3 10Output
8Input
2 1 1000000000Output
999999999Input
4 3 5 7 11Output
10