func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T abs(T t) {     return t < 0 ? -t : t;   }   const long long modn = 1000000007;   inline long long mod(long long x) { return x % modn; }   const int N = 1000009;   int a[N], t[N];   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int A, B, n;   long long memo[N][2][2];   long long solve(int i, bool on, bool first) {     if (i == n) return (first && on) ? 100000000000000000ll : 0ll;     if (!on && t[i] == 2) return 100000000000000000ll;     long long &r = memo[i][on][first];     if (r != -1) return r;     if (on)       r = min(solve(i, false, first), solve(i + 1, true, first) + A);     else       r = solve(i + 1, false, first) + (t[i] == 1 ? B : 0ll);     return r;   }   void add_ps(set<int> &p, int x) {     for (int i = 2; i * i <= x; i++) {       if (!(x % i)) p.insert(i);       while (!(x % i)) x /= i;     }     if (x > 1) p.insert(x);   }   int main() {     int i;     scanf( %d %d %d , &n, &A, &B);     for (i = 0; i < n; i++) scanf( %d , &a[i]);     set<int> p;     for (i = -1; i <= 1; i++) add_ps(p, a[0] + i), add_ps(p, a[n - 1] + i);     long long ans = LLONG_MAX;     for (int x : p) {       for (i = 0; i < n; i++)         if ((a[i] % x) == 0)           t[i] = 0;         else if (!((a[i] + 1) % x) || !((a[i] - 1) % x))           t[i] = 1;         else           t[i] = 2;       memset(memo, -1, sizeof memo);       long long cur = 0;       for (i = 0; i < n; i++) {         ans = min(ans, cur + solve(i, true, !i));         if (t[i] == 1)           cur += B;         else if (t[i] == 2)           break;       }     }     printf( %I64d n , ans);   }   