#include <bits/stdc++.h>
using namespace std;
long long dp[1000100][3];
int val[1000100];
long long a, b;
int prime[1000100];
int vis[1000100];
int n, cnt, fac[1000100];
void init() {
  for (int i = 2; i < 1000100; i++) {
    if (!vis[i]) prime[cnt++] = i;
    for (int j = 0; j < cnt && prime[j] * i < 1000100; j++) {
      vis[prime[j] * i] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
long long solve(int st, int ed, int v) {
  memset(dp, 0x3f3f3f3f3f3f3f3f, sizeof(dp));
  dp[st - 1][0] = 0;
  for (int i = st; i <= ed; i++) {
    dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + a;
    if (val[i] % v != 0) {
      if ((val[i] + 1) % v == 0 || (val[i] - 1) % v == 0) {
        dp[i][0] = dp[i - 1][0] + b;
        dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]) + b;
      }
    } else {
      dp[i][0] = dp[i - 1][0];
      dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]);
    }
  }
  return min(min(dp[ed][0], dp[ed][1]), dp[ed][2]);
}
int factor(int x) {
  int tot = 0;
  for (int j = 0; j < cnt && x >= prime[j]; j++) {
    if (x % prime[j] == 0) {
      fac[tot++] = prime[j];
      while (x % prime[j] == 0) x /= prime[j];
    }
  }
  if (x != 1) fac[tot++] = x;
  return tot;
}
int main() {
  int t, C = 1;
  init();
  while (scanf("%d%lld%lld", &n, &a, &b) != EOF) {
    for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
    long long ans = a * (long long)n;
    for (int i = -1; i <= 1; i++) {
      long long cost = i == 0 ? 0 : b;
      int len = factor(val[n] + i);
      for (int j = 0; j < len; j++)
        ans = min(ans, solve(1, n - 1, fac[j]) + cost);
      len = factor(val[1] + i);
      for (int j = 0; j < len; j++) ans = min(ans, solve(2, n, fac[j]) + cost);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
