#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char i = getchar();
  long long f = 1, res = 0;
  while (i < '0' || i > '9') {
    if (i == '-') f = -1;
    i = getchar();
  }
  while (i >= '0' && i <= '9') {
    res = res * 10 + i - '0';
    i = getchar();
  }
  return f * res;
}
const long long inf = 1e18;
;
const int N = 1e6 + 50;
long long n, a, b, v[N];
long long dp[N][3], cost[N];
long long fac[500], res;
inline long long solve(long long x) {
  memset(dp, 0, sizeof dp);
  for (long long i = 1; i <= n; ++i) {
    if (v[i] % x == 0)
      cost[i] = 0;
    else if ((v[i] + 1) % x == 0 || (v[i] - 1) % x == 0)
      cost[i] = b;
    else
      cost[i] = inf;
  }
  for (long long 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]));
}
inline void init(long long x) {
  for (long long i = 2; i * i <= x; ++i) {
    if (x % i) continue;
    fac[res++] = i;
    while (x % i == 0) x /= i;
  }
  if (x > 1) fac[res++] = x;
}
int main() {
  while (~scanf("%I64d%I64d%I64d", &n, &a, &b)) {
    for (long long i = 1; i <= n; ++i) v[i] = read();
    res = 0;
    init(v[1] + 1);
    init(v[1]);
    init(v[1] - 1);
    init(v[n] + 1);
    init(v[n]);
    init(v[n] - 1);
    sort(fac, fac + res);
    res = unique(fac, fac + res) - fac;
    long long ans = inf;
    for (long long i = 0; i < res; ++i) ans = min(ans, solve(fac[i]));
    printf("%I64d\n", ans);
  }
}
