#include <bits/stdc++.h>
const int N = 1000100;
const long long OO = 1e16;
long long d[N][3];
int a[N];
int n, pa, pb;
long long calc(int dv, int n) {
  for (int i = 0; i < n; ++i) d[i][0] = d[i][1] = d[i][2] = 0;
  d[0][0] = a[0] % dv == 0         ? 0
            : (a[0] + 1) % dv == 0 ? pb
            : (a[0] - 1) % dv == 0 ? pb
                                   : OO;
  d[0][1] = pa;
  d[0][2] = pa;
  for (int i = 1; i < n; ++i) {
    long long cur = a[i] % dv == 0         ? 0
                    : (a[i] + 1) % dv == 0 ? pb
                    : (a[i] - 1) % dv == 0 ? pb
                                           : OO;
    d[i][0] = d[i - 1][0] + cur;
    d[i][1] = d[i - 1][1] < d[i - 1][0] ? d[i - 1][1] + pa : d[i - 1][0] + pa;
    d[i][2] = d[i][1] < d[i - 1][2] + cur ? d[i][1] : d[i - 1][2] + cur;
    for (int j = 0; j < 3; ++j)
      if (d[i][j] > OO) d[i][j] = OO;
  }
  long long r = d[n - 1][0] < d[n - 1][2] ? d[n - 1][0] : d[n - 1][2];
  for (int i = 0; i < n; ++i) {
    long long cur = d[i][0] + 1LL * (n - i - 1) * pa;
    if (cur < r) r = cur;
  }
  return r;
}
long long solve(int m, int x = 0) {
  int val = a[x];
  long long minR = OO;
  if (m == 1) return minR;
  int k = m;
  for (int i = 2; i * i <= k; ++i)
    if (m % i == 0) {
      while (m % i == 0) m /= i;
      a[x] = i;
      long long r = calc(i, x == 0 ? n : n - 1);
      if (r < minR) minR = r;
    }
  if (m > 1) {
    a[x] = m;
    long long r = calc(m, x == 0 ? n : n - 1);
    if (r < minR) minR = r;
  }
  a[x] = val;
  return minR;
}
int main() {
  scanf("%d%d%d", &n, &pa, &pb);
  if (n == 1 || pa == 0) {
    puts("0");
    return 0;
  }
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  long long r = solve(a[0]);
  long long r1 = solve(a[0] - 1) + pb;
  if (r1 < r) r = r1;
  r1 = solve(a[0] + 1) + pb;
  if (r1 < r) r = r1;
  r1 = solve(a[n - 1], n - 1);
  if (r1 < r) r = r1;
  r1 = solve(a[n - 1] - 1, n - 1) + pb;
  if (r1 < r) r = r1;
  r1 = solve(a[n - 1] + 1, n - 1) + pb;
  if (r1 < r) r = r1;
  printf("%I64d\n", r);
  return 0;
}
