#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x7ffffffffffffff;
const int maxn = 1000010;
int n, a, b;
int num[maxn];
long long ans = 0;
long long fac[1010];
inline void init(int x) {
  for (register int i = 2; i * i <= x; i++) {
    if (x % i) continue;
    fac[++fac[0]] = i;
    while (x % i == 0) x /= i;
  }
  if (x > 1) fac[++fac[0]] = x;
}
long long dp[maxn][3];
long long cost[maxn];
inline long long solve(int x) {
  memset(dp, 0, sizeof(dp));
  ;
  for (register int i = 1; i <= n; i++) {
    if (num[i] % x == 0)
      cost[i] = 0;
    else if ((num[i] + 1) % x == 0 || (num[i] - 1) % x == 0)
      cost[i] = b;
    else
      cost[i] = inf;
  }
  for (register int i = 1; i <= n; i++) {
    if (cost[i] == inf) {
      dp[i][0] = inf;
      dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + a;
      dp[i][2] = inf;
    } else {
      dp[i][0] = dp[i - 1][0] + cost[i];
      dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + a;
      dp[i][2] = min(dp[i - 1][2], dp[i - 1][1]) + cost[i];
    }
  }
  return min(dp[n][0], min(dp[n][1], dp[n][2]));
}
int main() {
  scanf("%d%d%d", &n, &a, &b);
  for (register int i = 1; i <= n; i++) {
    scanf("%d", &num[i]);
  }
  init(num[1] - 1);
  init(num[1]);
  init(num[1] + 1);
  init(num[n] - 1);
  init(num[n]);
  init(num[n] + 1);
  sort(fac + 1, fac + 1 + fac[0]);
  fac[0] = unique(fac + 1, fac + 1 + fac[0]) - fac - 1;
  long long ans = inf;
  for (register int i = 1; i <= fac[0]; i++) {
    ans = min(ans, solve(fac[i]));
  }
  printf("%lld\n", ans);
  return 0;
}
