func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 1000000000;   const int MAX = 1000007;   int n;   long long a, b;   vector<int> primes(int x) {     vector<int> p;     for (int i = 2; i * i <= x; ++i)       if (x % i == 0) {         p.push_back(i);         while (x % i == 0) {           x /= i;         }       }     if (x != 1) p.push_back(x);     return p;   }   long long dp[MAX][3];   long long solve(vector<int> c) {     vector<int> p = primes(c[0]);     vector<int> p1 = primes(c[0] - 1);     for (int i = (0); i < (p1.size()); i++) p.push_back(p1[i]);     p1 = primes(c[0] + 1);     for (int i = (0); i < (p1.size()); i++) p.push_back(p1[i]);     p1 = primes(c.back());     for (int i = (0); i < (p1.size()); i++) p.push_back(p1[i]);     p1 = primes(c.back() + 1);     for (int i = (0); i < (p1.size()); i++) p.push_back(p1[i]);     p1 = primes(c.back() - 1);     for (int i = (0); i < (p1.size()); i++) p.push_back(p1[i]);     sort(p.begin(), p.end());     p.resize(unique(p.begin(), p.end()) - p.begin());     long long res = 1LL * INF * INF;     for (int t = (0); t < (p.size()); t++) {       int pr = p[t];       dp[0][0] = dp[0][1] = dp[0][2] = 0;       for (int i = (0); i < (n); i++) {         int val = min(c[i] % pr, pr - c[i] % pr);         dp[i + 1][0] = dp[i + 1][1] = dp[i + 1][2] = 1LL * INF * INF;         if (val <= 1) {           dp[i + 1][2] = min(dp[i][2] + a * val,                              min(dp[i][1] + a * val, dp[i][0] + a * val));         }         dp[i + 1][1] = min(dp[i][0], dp[i][1]) + b;         if (val <= 1) {           dp[i + 1][0] = dp[i][0] + a * val;         }       }       long long r = min(dp[n][2], min(dp[n][1], dp[n][0]));       res = min(res, r);     }     return res;   }   int main() {     cin >> n >> a >> b;     swap(a, b);     vector<int> c(n);     for (int i = (0); i < (n); i++) {       scanf( %d , &c[i]);     }     long long res = solve(c);     cout << res << endl;     return 0;   }   