#include <bits/stdc++.h>
using namespace std;
const long long inf(0x3f3f3f3f3f3f3f3fll);
long long f[1000011][3];
int p[105], pt, ar[1000011], n, a, b;
void dc(int x) {
  if (x < 2) return;
  int i, j(ceil(sqrt(x)));
  for (i = 2; i <= j; ++i)
    if (x % i == 0) {
      p[pt++] = i;
      while (x % i == 0) x /= i;
    }
  if (x > 1) p[pt++] = x;
}
int main() {
  int i, j;
  long long ans(inf);
  scanf("%d%d%d", &n, &a, &b);
  for (i = 0; i < n; ++i) scanf("%d", ar + i);
  if (n == 1) {
    printf("0\n");
    return 0;
  }
  for (i = -1; i <= 1; ++i) {
    dc(ar[0] + i);
    dc(ar[n - 1] + i);
  }
  sort(p, p + pt);
  pt = unique(p, p + pt) - p;
  for (i = 0; i < pt; ++i) {
    f[0][1] = a;
    if (ar[0] % p[i] == 0)
      f[0][0] = 0;
    else if ((ar[0] + 1) % p[i] == 0 || (ar[0] - 1) % p[i] == 0)
      f[0][0] = b;
    else
      f[0][0] = inf;
    f[0][2] = min(f[0][0], f[0][1]);
    for (j = 1; j < n; ++j) {
      if (ar[j] % p[i] == 0) {
        f[j][0] = f[j - 1][0];
        f[j][1] = min(f[j - 1][0], f[j - 1][1]) + a;
        f[j][2] = min(min(f[j][0], f[j][1]), f[j - 1][2]);
      } else if ((ar[j] + 1) % p[i] == 0 || (ar[j] - 1) % p[i] == 0) {
        f[j][0] = f[j - 1][0] + b;
        f[j][1] = min(f[j - 1][0], f[j - 1][1]) + a;
        f[j][2] = min(min(f[j][0], f[j][1]), f[j - 1][2] + b);
      } else {
        f[j][0] = inf;
        f[j][1] = min(f[j - 1][0], f[j - 1][1]) + a;
        f[j][2] = f[j][1];
      }
    }
    ans = min(ans, f[n - 1][2]);
  }
  printf("%I64d\n", ans);
  return 0;
}
