#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
void arquivo() {
  freopen("", "r", stdin);
  freopen("", "w", stdout);
}
const int N = 5000100;
int n;
long long a, b;
int v[N];
bool memo[N][3];
long long pd[N][3];
int atPrime;
long long func(int pos, int op) {
  if (pos == n) return 0LL;
  if (memo[pos][op]) return pd[pos][op];
  long long ret = 1000000000000000001LL;
  if (!op) {
    ret = func(pos + 1, 1) + a;
    if (v[pos] % atPrime == 0) ret = min(ret, func(pos + 1, 0));
    if ((v[pos] + 1) % atPrime == 0) ret = min(ret, func(pos + 1, 0) + b);
    if ((v[pos] - 1) % atPrime == 0) ret = min(ret, func(pos + 1, 0) + b);
  } else if (op == 1) {
    ret = func(pos + 1, 1) + a;
    if (v[pos] % atPrime == 0) ret = min(ret, func(pos + 1, 2));
    if ((v[pos] + 1) % atPrime == 0) ret = min(ret, func(pos + 1, 2) + b);
    if ((v[pos] - 1) % atPrime == 0) ret = min(ret, func(pos + 1, 2) + b);
  } else {
    if (v[pos] % atPrime == 0) ret = min(ret, func(pos + 1, 2));
    if ((v[pos] + 1) % atPrime == 0) ret = min(ret, func(pos + 1, 2) + b);
    if ((v[pos] - 1) % atPrime == 0) ret = min(ret, func(pos + 1, 2) + b);
  }
  memo[pos][op] = 1;
  return pd[pos][op] = ret;
}
void fatora(long long x, set<int> &all) {
  for (long long i = 2; i * i <= x; ++i) {
    if (x % i == 0) {
      all.insert(i);
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) all.insert(x);
}
int main() {
  scanf("%d %lld %lld", &n, &a, &b);
  set<int> all;
  long long x;
  for (int i = 0; i < n; ++i) {
    scanf("%d", v + i);
  }
  for (int i = 0; i < 1; ++i) {
    x = v[i];
    fatora(x, all);
    x = v[i] + 1;
    fatora(x, all);
    x = v[i] - 1;
    fatora(x, all);
  }
  for (int i = n - 1; i < n; ++i) {
    x = v[i];
    fatora(x, all);
    x = v[i] + 1;
    fatora(x, all);
    x = v[i] - 1;
    fatora(x, all);
  }
  long long ans = (long long)(n - 1LL) * a;
  for (set<int>::iterator it = all.begin(); it != all.end(); it++) {
    atPrime = *it;
    if (atPrime == 1) continue;
    memset(memo, 0, sizeof memo);
    for (int j = n - 1; j >= 0; --j) {
      func(j, 0);
      func(j, 1);
      func(j, 2);
    }
    ans = min(ans, func(0, 0));
  }
  printf("%lld\n", ans);
  return 0;
}
