#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long mod2 = 998244353;
const long long inf = 2e18;
const double tiaohe = 0.57721566490153286060651209;
long long oula(long long x) {
  long long res = x;
  for (int i = 2; i <= x / i; ++i) {
    if (x % i == 0) {
      res = res / i * (i - 1);
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) res = res / x * (x - 1);
  return res;
}
long long quickmod(long long a, long long n, long long m) {
  long long s = 1;
  while (n) {
    if (n & 1) {
      s = s * a % m;
    }
    a = (a * a) % m;
    n = n / 2;
  }
  return s;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void ex_gcd(long long a, long long b, long long &x, long long &y,
            long long &d) {
  if (!b) {
    d = a, x = 1, y = 0;
  } else {
    ex_gcd(b, a % b, y, x, d);
    y -= x * (a / b);
  }
}
long long inv(long long t, long long p) {
  long long d, x, y;
  ex_gcd(t, p, x, y, d);
  return d == 1 ? (x % p + p) % p : -1;
}
bool isPrime(long long x) {
  if (x == 2) return true;
  if (x % 2 == 0) return false;
  for (long long i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
inline long long in() {
  char ch = getchar();
  long long x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
void print(double x) { printf("%.6lf\n", x); }
double eqa = (1 + sqrt(5.0)) / 2.0;
double E = 2.7182818284;
const double eps = 1e-8;
double pi = acos(-1);
const int N = 1e6 + 100;
int p[N], cnt;
int c[N];
int n, a, b;
long long dp[N][3];
void get(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      p[++cnt] = i;
      while (x % i == 0) {
        x /= i;
      }
    }
  }
  if (x > 1) {
    p[++cnt] = x;
  }
}
void mem(int n) {
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= 2; ++j) dp[i][j] = 2e18;
  }
  dp[0][0] = 0;
}
int main() {
  cin >> n >> a >> b;
  for (int i = 1; i <= n; ++i) c[i] = in();
  get(c[1]);
  get(c[1] - 1);
  get(c[1] + 1);
  get(c[n] - 1);
  get(c[n]);
  get(c[n] + 1);
  sort(p + 1, p + 1 + cnt);
  cnt = unique(p + 1, p + 1 + cnt) - (p + 1);
  long long res = 2e18;
  for (int j = 1; j <= cnt; ++j) {
    mem(n + 1);
    for (int i = 1; i <= n; ++i) {
      if (c[i] % p[j] == 0) {
        dp[i][0] = min(dp[i][0], dp[i - 1][0]);
        dp[i][2] = min(dp[i][2], dp[i - 1][2]);
        dp[i][1] = min(dp[i][1], dp[i - 1][1] + a);
        dp[i][2] = min(dp[i][2], dp[i - 1][1]);
      } else {
        if ((c[i] - 1) % p[j] == 0 || (c[i] + 1) % p[j] == 0) {
          dp[i][2] = min(dp[i][2], dp[i - 1][2] + b);
          dp[i][2] = min(dp[i - 1][1] + b, dp[i][2]);
          dp[i][0] = min(dp[i][0], dp[i - 1][0] + b);
        }
        dp[i][1] = min(dp[i][1], dp[i - 1][1] + a);
        dp[i][2] = min(dp[i][2], dp[i - 1][1] + a);
        dp[i][1] = min(dp[i][1], dp[i - 1][0] + a);
      }
    }
    for (int k = 0; k <= 2; ++k) {
      res = min(res, dp[n][k]);
    }
  }
  cout << res << endl;
  return 0;
}
