#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = 2 * acos((long double)0);
long long gcd(long long a, long long b) {
  long long r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
void submod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) < 0) a += p;
}
const int maxn = 1000010;
int n, x, y;
int a[maxn];
long long ans;
int checkprime(int k) {
  if (k < 2) return 0;
  for (long long i = 2; i * i <= k; i++) {
    if (k % i == 0) return 0;
  }
  return 1;
}
void go() {
  vector<int> div;
  for (long long i = 2; i * i <= a[0]; i++) {
    if (a[0] % i == 0) {
      if (checkprime(i)) div.push_back(i);
      int d = a[0] / i;
      if (d != i && checkprime(d)) div.push_back(d);
    }
  }
  if (checkprime(a[0])) div.push_back(a[0]);
  for (int k = (0); k < (int((div).size())); k++) {
    int p = div[k];
    long long tot = 0;
    vector<long long> vl;
    for (int i = (0); i < (n); i++) {
      if (a[i] % p == 1)
        tot += y;
      else if (a[i] % p == p - 1)
        tot += y;
      else if (a[i] % p)
        break;
      vl.push_back(tot);
      ans = min(ans, tot + (long long)(n - i - 1) * x);
    }
    tot = 0;
    vector<long long> vl2;
    for (int i = (n)-1; i >= (0); i--) {
      if (a[i] % p == 1)
        tot += y;
      else if (a[i] % p == p - 1)
        tot += y;
      else if (a[i] % p)
        break;
      vl2.push_back(tot);
    }
    reverse((vl2).begin(), (vl2).end());
    int cur = 0;
    long long dmin = LINF;
    for (int i = (0); i < (int((vl2).size())); i++) {
      int idx = n - int((vl2).size()) + i;
      while (cur < idx && cur < int((vl).size())) {
        dmin = min(dmin, vl[cur] - (long long)cur * x);
        cur++;
      }
      if (idx) ans = min(ans, dmin + vl2[i] + (long long)(idx - 1) * x);
      ans = min(ans, vl2[i] + (long long)idx * x);
    }
  }
}
long long res = LINF;
void abc() {
  ans = LINF;
  go();
  res = min(res, ans);
  a[0]--;
  ans = LINF;
  go();
  res = min(res, ans + y);
  a[0] += 2;
  ans = LINF;
  go();
  res = min(res, ans + y);
  a[0]--;
}
void solve() {
  scanf("%d%d%d", &n, &x, &y);
  for (int i = (0); i < (n); i++) scanf("%d", a + i);
  abc();
  reverse(a, a + n);
  abc();
  printf("%I64d", res);
}
int main() {
  solve();
  return 0;
}
