#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long maxn = 1e9 + 7;
const double PI = acos(-1);
int prime[100000];
int isprime[100000];
int num;
int ai[1000050];
int ok[100000];
void init() {
  memset(prime, 0, sizeof(prime));
  memset(isprime, 0, sizeof(isprime));
  for (int i = 2; i < 100000; i++) {
    if (!isprime[i]) {
      prime[num++] = i;
    }
    for (int j = i * 2; j < 100000; j += i) {
      isprime[j] = 1;
    }
  }
}
long long n, a, b;
long long dp[1000050][3];
long long solve(int aa) {
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < 3; j++) dp[i][j] = 1e18;
  }
  dp[0][0] = 0;
  dp[0][1] = 0;
  for (int i = 0; i < n; i++) {
    if (((ai[i] - 1) % aa == 0) || (((ai[i] + 1) % aa == 0))) {
      dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + b);
      dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + a);
      dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a);
      dp[i + 1][2] = min(dp[i + 1][2], dp[i][1] + b);
      dp[i + 1][2] = min(dp[i + 1][2], dp[i][2] + b);
    } else if (ai[i] % aa == 0) {
      dp[i + 1][0] = min(dp[i + 1][0], dp[i][0]);
      dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a);
      dp[i + 1][2] = min(dp[i + 1][2], dp[i][1]);
      dp[i + 1][2] = min(dp[i + 1][2], dp[i][2]);
    } else {
      dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + a);
      dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a);
    }
  }
  long long res = min(dp[n][0], dp[n][1]);
  res = min(res, dp[n][2]);
  return res;
}
int main() {
  cin >> n >> a >> b;
  memset(ok, 0, sizeof(ok));
  init();
  for (int i = 0; i < n; i++) scanf("%d", &ai[i]);
  long long ans = 1e18;
  long long zz = 0;
  for (int j = -1; j <= 1; j++) {
    int mm = ai[0] + j;
    for (int i = 0; i < num; i++) {
      if (mm % prime[i] == 0) {
        while (mm % prime[i] == 0) mm /= prime[i];
        if (ok[prime[i]]) continue;
        ans = min(ans, solve(prime[i]));
        ok[prime[i]] = 1;
      }
    }
    if (mm != 1) {
      ans = min(ans, solve(mm));
      zz = mm;
    }
  }
  for (int j = -1; j <= 1; j++) {
    int mm = ai[n - 1] + j;
    for (int i = 0; i < num; i++) {
      if (mm % prime[i] == 0) {
        while (mm % prime[i] == 0) mm /= prime[i];
        if (ok[prime[i]]) continue;
        ans = min(ans, solve(prime[i]));
        ok[prime[i]] = 1;
      }
    }
    if (mm != 1) {
      ans = min(ans, solve(mm));
      zz = mm;
    }
  }
  cout << ans << endl;
  return 0;
}
