#include <bits/stdc++.h>
using namespace std;
int n;
long long a, b, v[1000005];
long long dp[1000005][3], dp2[1000005][3];
vector<int> primes;
void sieve(int m) {
  bitset<1000005> isPrime;
  isPrime.set();
  isPrime[0] = isPrime[1] = 0;
  for (long long i = 2; i <= m; ++i)
    if (isPrime[i]) {
      for (long long j = i * i; j <= m; j += i) isPrime[j] = 0;
      primes.push_back(i);
    }
}
vector<int> factors(int n) {
  vector<int> fac;
  int i = 0, pf = primes[0];
  while (n > 1) {
    if (n % pf == 0) fac.push_back(pf);
    while (n > 1 && n % pf == 0) n /= pf;
    ++i;
    if (i >= (int)primes.size() && n > 1) {
      fac.push_back(n);
      break;
    }
    pf = primes[i];
  }
  return fac;
}
void opt(int pf) {
  for (int k = 0; k < 3; ++k) dp[n][k] = dp2[n - 1][k] = 0;
  memset(dp2, 0, sizeof(dp2));
  for (int j = n - 1; j >= 0; --j)
    for (int k = 2; k >= 0; --k) {
      long long &ret = dp[j][k];
      long long &ret2 = dp2[j][k];
      ret = 0x3f3f3f3f3f3f3f3fLL;
      if (j < n - 1) ret2 = 0x3f3f3f3f3f3f3f3fLL;
      if (k == 0) {
        ret = min(ret, a + dp[(j + 1)][1]);
        if (j < n - 1) ret2 = min(ret2, a + dp2[(j + 1)][1]);
      }
      if (k == 1) {
        ret = min(ret, dp[j][2]);
        ret = min(ret, a + dp[(j + 1)][1]);
        if (j < n - 1) {
          ret2 = min(ret2, dp2[j][2]);
          ret2 = min(ret2, a + dp2[(j + 1)][1]);
        }
      }
      if (k == 0 || k == 2) {
        if (v[j] % pf == 0) {
          ret = min(ret, dp[(j + 1)][k]);
          if (j < n - 1) ret2 = min(ret2, dp2[(j + 1)][k]);
        }
        if ((v[j] + 1) % pf == 0 || (v[j] - 1) % pf == 0) {
          ret = min(ret, b + dp[(j + 1)][k]);
          if (j < n - 1) ret2 = min(ret2, b + dp2[(j + 1)][k]);
        }
      }
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> a >> b;
  for (int i = 0; i < n; ++i) cin >> v[i];
  sieve(1000005 - 1);
  vector<int> vfac[6];
  vfac[0] = factors(v[0]);
  vfac[1] = factors(v[n - 1]);
  vfac[2] = factors(v[0] + 1);
  vfac[3] = factors(v[n - 1] + 1);
  if (v[0] > 0) vfac[4] = factors(v[0] - 1);
  if (v[n - 1] > 0) vfac[5] = factors(v[n - 1] - 1);
  vector<int> fac;
  for (int i = 0; i < 6; ++i)
    fac.insert(fac.end(), vfac[i].begin(), vfac[i].end());
  set<int> tree;
  long long sol = 0x3f3f3f3f3f3f3f3fLL;
  for (int i = 0; i < (int)fac.size(); ++i) {
    if (tree.find(fac[i]) != tree.end()) continue;
    tree.insert(fac[i]);
    opt(fac[i]);
    if (v[0] % fac[i] == 0) sol = min(sol, dp[1][0]);
    if ((v[0] + 1) % fac[i] == 0) sol = min(sol, b + dp[1][0]);
    if (v[0] > 0 && (v[0] - 1) % fac[i] == 0) sol = min(sol, b + dp[1][0]);
    if (v[n - 1] % fac[i] == 0) sol = min(sol, dp2[0][0]);
    if ((v[n - 1] + 1) % fac[i] == 0) sol = min(sol, b + dp2[0][0]);
    if (v[n - 1] > 0 && (v[n - 1] - 1) % fac[i] == 0)
      sol = min(sol, b + dp2[0][0]);
  }
  cout << sol << endl;
  return 0;
}
