#include <bits/stdc++.h>
using namespace std;
void ga(int N, int *A) {
  for (int i(0); i < N; i++) scanf("%d", A + i);
}
long long P[(1000006) >> 1] = {2}, L(1), cn[(1000006) >> 5];
void gen() {
  (cn[0 >> 6] |= 1ULL << ((0 & 63))), (cn[1 >> 6] |= 1ULL << ((1 & 63)));
  int Q(1 + sqrt((1 << 17)));
  for (int k(3); k <= Q; k += 2)
    if (!((cn[k >> 6] >> (k & 63)) & 1))
      for (long long h(k << 1), j(k * k); j < (1 << 17); j += h)
        (cn[j >> 6] |= 1ULL << ((j & 63)));
  for (int i(3); i < (1 << 17); i += 2)
    if (!((cn[i >> 6] >> (i & 63)) & 1)) P[L++] = i;
}
int fc(int N, int *f, int *c) {
  int L(0);
  for (int i(0), h(0); N >= P[i] * P[i]; ++i, h = 0) {
    while (!(N % P[i])) ++h, N /= P[i];
    if (h) f[L] = P[i], c[L++] = h;
  }
  if (N > 1) f[L] = N, c[L++] = 1;
  return L;
}
int N, A[(1000006)], a, b, f[16], c[16], W, sx[] = {1, 0, -1};
long long dp[(1000006)][2][2], B((1ll << 60));
long long dyn(int u, int d, int f) {
  if (u == N) return 0;
  long long &v(dp[u][d][f]);
  if (~v) return v;
  v = (1ll << 60);
  for (int i(0); i < 3; i++)
    if (!((A[u] + sx[i]) % W)) v = min(v, dyn(u + 1, d, 0) + (sx[i] ? b : 0));
  if (!d || f) v = min(v, a + dyn(u + 1, 1, 1));
  return v;
}
int main(void) {
  gen();
  scanf("%d%d%d", &N, &a, &b), ga(N, A);
  for (int i(0); i < 3; i++) {
    int l = fc(A[0] + sx[i], f, c), p(sx[i] ? b : 0);
    for (int i(0); i < l; i++)
      (memset(dp, -1, sizeof(dp))), W = f[i], B = min(B, dyn(1, 0, 0) + p);
  }
  --N;
  for (int i(0); i < 3; i++) {
    (memset(dp, -1, sizeof(dp)));
    int l = fc(A[N] + sx[i], f, c), p(sx[i] ? b : 0);
    for (int i(0); i < l; i++)
      (memset(dp, -1, sizeof(dp))), W = f[i], B = min(B, dyn(0, 1, 1) + p);
  }
  printf("%lld\n", B);
  return 0;
}
