#include <bits/stdc++.h>
using namespace std;
const int maxn = 1E6 + 10;
map<int, bool> M;
long long n, a, b, num[maxn], f[maxn], g[maxn], mi[maxn], mi2[maxn], ans = 1E17;
bool flag;
void cal(long long x) {
  int R = 0;
  f[0] = mi[0] = g[n + 1] = 0;
  mi2[n + 1] = 1LL * (n + 1) * a;
  for (int i = 1; i <= n; i++) {
    long long sum;
    if (num[i] % x == 0)
      sum = 0;
    else if ((num[i] + 1) % x == 0)
      sum = b;
    else if ((num[i] - 1) % x == 0 && num[i] - 1 > 0)
      sum = b;
    else {
      R = i;
      break;
    }
    f[i] = f[i - 1] + sum;
    mi[i] = min(f[i] - 1LL * a * 1LL * i, mi[i - 1]);
    if (i == n) ans = min(ans, f[i]);
  }
  if (R)
    for (int i = R; i <= n; i++) mi[i] = mi[i - 1];
  long long L = 0;
  for (int i = n; i; i--) {
    long long sum;
    if (num[i] % x == 0 && num[i])
      sum = 0;
    else if ((num[i] + 1) % x == 0 && num[i] + 1 > 0)
      sum = b;
    else if ((num[i] - 1) % x == 0 && num[i] - 1 > 0)
      sum = b;
    else {
      L = i;
      break;
    }
    g[i] = g[i + 1] + sum;
    mi2[i] = min(mi2[i + 1], g[i] + 1LL * a * 1LL * i);
    if (i == 1) ans = min(ans, g[i]);
  }
  if (L)
    for (int i = L; i; i--) mi2[i] = mi2[i + 1];
  for (int i = 1; i <= n + 1; i++) ans = min(ans, mi[i - 1] + mi2[i] - a);
}
long long ksm(long long a, long long x, long long y) {
  if (x == 0) return 1;
  long long r = ksm(a, x / 2, y);
  long long ret = r * r % y;
  if (ret == 1 && r != 1 && r != y - 1) flag = 0;
  if (x & 1) ret = ret * a % y;
  return ret;
}
bool M_B(long long x) {
  for (int i = 1; i <= 10; i++) {
    flag = true;
    long long a = rand() % (x - 1) + 1;
    long long ret = ksm(a, x - 1, x);
    if (ret != 1 || !flag) return false;
  }
  return true;
}
void solve(long long now) {
  if (now <= 1) return;
  if (M_B(now) && !M[now])
    cal(now), M[now] = 1;
  else {
    long long SQRT = sqrt(now);
    for (int i = 2; i <= SQRT; i++)
      if (now % i == 0) {
        if (M_B(i) && !M[i]) cal(i), M[i] = 1;
        long long j = now / i;
        if (M_B(j) && !M[j]) cal(j), M[j] = 1;
      }
  }
}
int main() {
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) scanf("%I64d", &num[i]);
  solve(num[1]);
  solve(num[1] - 1);
  solve(num[1] + 1);
  solve(num[n]);
  solve(num[n] - 1);
  solve(num[n] + 1);
  cout << ans;
  return 0;
}
