#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000000;
const int MAXD = 15;
const int MAXS = 3;
const long long INF = 100000000000000000LL;
long long dp[MAXN][3];
int a[MAXN];
vector<int> factorization(long long n) {
  vector<int> factors;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) {
        n /= i;
      }
      factors.push_back(i);
    }
  }
  if (n > 1) {
    factors.push_back(n);
  }
  return factors;
}
long long factdp(int n, long long rem, long long add, long long fact) {
  dp[0][0] = dp[0][1] = dp[0][2] = 0;
  for (int i = 1; i < n; i++) {
    dp[i][0] = dp[i][1] = dp[i][2] = INF;
    dp[i][1] = min(dp[i - 1][0] + rem, dp[i - 1][1] + rem);
    for (int k = -1; k <= 1; k++) {
      if ((a[i] + k) % fact == 0) {
        long long cost = (k == 0) ? 0 : add;
        dp[i][0] = min(dp[i][0], dp[i - 1][0] + cost);
        dp[i][2] = min(dp[i][2], dp[i - 1][1] + cost);
        dp[i][2] = min(dp[i][2], dp[i - 1][2] + cost);
      }
    }
  }
  return min(dp[n - 1][0], min(dp[n - 1][1], dp[n - 1][2]));
}
long long finddp(int n, long long rem, long long add) {
  if (a[0] == 1) {
    return INF;
  }
  vector<int> fact = factorization(a[0]);
  int nfact = (int)fact.size();
  long long mindp = INF;
  for (int i = 0; i < fact.size(); i++) {
    mindp = min(mindp, factdp(n, rem, add, fact[i]));
  }
  return mindp;
}
long long getdp(int n, long long rem, long long add) {
  long long mindp = finddp(n, rem, add);
  a[0] += 1;
  mindp = min(mindp, finddp(n, rem, add) + add);
  a[0] -= 2;
  mindp = min(mindp, finddp(n, rem, add) + add);
  a[0]++;
  return mindp;
}
void solve() {
  int n;
  scanf("%d", &n);
  int rem, add;
  scanf("%d%d", &rem, &add);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  long long mindp = getdp(n, rem, add);
  reverse(a, a + n);
  mindp = min(mindp, getdp(n, rem, add));
  cout << mindp;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
    cout << endl;
  }
}
