func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T read() {     register T sum = 0;     register char cc = getchar();     int sym = 1;     while (cc !=  -  && (cc >  9  || cc <  0 )) cc = getchar();     if (cc ==  - ) sym = -1, cc = getchar();     sum = sum * 10 + cc -  0 ;     cc = getchar();     while (cc >=  0  && cc <=  9 ) sum = sum * 10 + cc -  0 , cc = getchar();     return sym * sum;   }   template <typename T>   inline T read(T& a) {     a = read<T>();     return a;   }   template <typename T, typename... Others>   inline void read(T& a, Others&... b) {     a = read(a);     read(b...);   }   int n, ans = 0x7fffffff, b[200010], prim[1000010];   long long a[200010];   set<long long> s;   void init() {     for (int i = 2; i <= 1000000; i++) {       if (!prim[i]) prim[++prim[0]] = i;       for (int j = 1; j <= prim[0] && i * prim[j] <= 1000000; j++) {         prim[i * prim[j]] = true;         if (i % prim[j]) break;       }     }   }   void div(long long x) {     for (int i = 1; i <= prim[0]; i++) {       if (x % prim[i]) continue;       s.insert(prim[i]);       while (x % prim[i] == 0) x /= prim[i];     }     if (x != 1) s.insert(x);   }   int solve(long long p) {     long long res = 0;     for (int i = 1; i <= n; i++) {       long long d = a[i] < p ? p - a[i] : min(a[i] % p, p - a[i] % p);       res = min(1ll * n, res + d);     }     return res;   }   int main() {     srand(time(NULL));     init();     read(n);     for (int i = 1; i <= n; i++) {       read(a[i]);       b[i] = i;     }     random_shuffle(b + 1, b + 1 + n);     for (int i = 1; i <= 100 && i <= n; i++) {       long long t = a[b[i]];       div(t);       div(t + 1);       if (t > 1) div(t - 1);     }     for (auto i : s) ans = min(ans, solve(i));     printf( %d n , ans);     return 0;   }   