#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
int p[1000], m[1000100];
long long l[1000100], r[1000100];
int main() {
  int i, j, k, n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  for (i = 0; i < n; scanf("%d", &m[i]), i++)
    ;
  k = 0;
  for (int l = m[0] - 1; l <= m[0] + 1; l++) {
    for (i = l, j = 2; j * j <= i; j++)
      if (i % j == 0)
        for (p[k++] = j; i % j == 0; i /= j)
          ;
    if (i > 1) p[k++] = i;
  }
  for (int l = m[n - 1] - 1; l <= m[n - 1] + 1; l++) {
    for (i = l, j = 2; j * j <= i; j++)
      if (i % j == 0)
        for (p[k++] = j; i % j == 0; i /= j)
          ;
    if (i > 1) p[k++] = i;
  }
  long long x = 1000000000000000000ll;
  for (j = 0; j < k; j++) {
    l[0] = 0;
    for (i = 0; i < n; i++)
      if (l[i] == -1)
        l[i + 1] = -1;
      else if (m[i] % p[j] == 0)
        l[i + 1] = l[i];
      else if ((m[i] - 1) % p[j] == 0)
        l[i + 1] = l[i] + b;
      else if ((m[i] + 1) % p[j] == 0)
        l[i + 1] = l[i] + b;
      else
        l[i + 1] = -1;
    r[n] = 0;
    for (i = n - 1; i >= 0; i--)
      if (r[i + 1] == -1)
        r[i] = -1;
      else if (m[i] % p[j] == 0)
        r[i] = r[i + 1];
      else if ((m[i] - 1) % p[j] == 0)
        r[i] = r[i + 1] + b;
      else if ((m[i] + 1) % p[j] == 0)
        r[i] = r[i + 1] + b;
      else
        r[i] = -1;
    long long d = l[0];
    for (i = 0; i < n; i++) {
      if (r[i] != -1) x = min(x, d + r[i]);
      if (l[i + 1] == -1)
        d += a;
      else
        d = min(l[i + 1], d + a);
    }
    x = min(x, d);
  }
  printf("%lld\n", x);
  return 0;
}
