#include <bits/stdc++.h>
using namespace std;
int a[1000111];
long long dp[1000111][3];
long long func(int num, int pr, long long a) {
  if (num % pr == 0) return 0LL;
  if ((num + 1) % pr == 0) return a;
  if ((num - 1) % pr == 0) return a;
  return 100000000000000000LL;
}
int main() {
  long long a1, b;
  int i, j, k, n;
  scanf("%d %lld %lld", &n, &a1, &b);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  if (n == 1) {
    printf("0\n");
    return 0;
  }
  vector<int> v;
  for (j = -1; j <= 1; j++) {
    k = a[0] + j;
    for (i = 2; i <= sqrt(k); i++) {
      if (k % i == 0) {
        while (k % i == 0) k /= i;
        v.push_back(i);
      }
    }
    if (k != 1) v.push_back(k);
    k = a[n - 1] + j;
    for (i = 2; i <= sqrt(k); i++) {
      if (k % i == 0) {
        while (k % i == 0) k /= i;
        v.push_back(i);
      }
    }
    if (k != 1) v.push_back(k);
  }
  long long ans = 100000000000000000LL;
  for (i = 0; i < v.size(); i++) {
    k = v[i];
    dp[0][0] = func(a[0], k, b);
    dp[0][1] = a1;
    dp[0][2] = func(a[0], k, b);
    for (j = 1; j < n; j++) {
      dp[j][0] = min(100000000000000000LL, dp[j - 1][0] + func(a[j], k, b));
      dp[j][1] = min(dp[j - 1][0] + a1, dp[j - 1][1] + a1);
      dp[j][2] = min(dp[j - 1][1], dp[j - 1][2]) + func(a[j], k, b);
      dp[j][0] = min(100000000000000000LL, dp[j][0]);
      dp[j][1] = min(100000000000000000LL, dp[j][1]);
      dp[j][2] = min(100000000000000000LL, dp[j][2]);
    }
    ans = min(ans, min(dp[n - 1][0], min(dp[n - 1][1], dp[n - 1][2])));
  }
  printf("%lld\n", ans);
  return 0;
}
