#include <bits/stdc++.h>
namespace chtholly {
char buf[1 << 23], *p1 = buf, *p2 = buf;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar()) f ^= c == '-';
  for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ '0');
  return f ? x : -x;
}
template <typename mitsuha>
inline bool read(mitsuha &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c) && ~c; c = getchar()) f ^= c == '-';
  if (!~c) return 0;
  for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ '0');
  return x = f ? x : -x, 1;
}
template <typename mitsuha>
inline int write(mitsuha x) {
  if (!x) return 0 & putchar(48);
  if (x < 0) putchar('-'), x = -x;
  int bit[20], i, p = 0;
  for (; x; x /= 10) bit[++p] = x % 10;
  for (i = p; i; --i) putchar(bit[i] + 48);
  return 0;
}
inline char fuhao() {
  char c = getchar();
  for (; isspace(c); c = getchar())
    ;
  return c;
}
}  // namespace chtholly
using namespace chtholly;
using namespace std;
const int yuzu = 1e6;
typedef long long fuko[yuzu | 10];
fuko c, p = {1, 1}, pr, dp[3];
vector<int> g;
void gpr(int n) {
  int i, j;
  for (i = 2; i <= n; ++i) {
    if (!p[i]) pr[++*pr] = i;
    for (j = 1; j <= *pr && i * pr[j] <= n; ++j) {
      p[i * pr[j]] = 1;
      if (i % pr[j] == 0) break;
    }
  }
}
void get(int x) {
  for (int i = 1; i <= *pr; ++i) {
    if (x % pr[i] == 0)
      for (g.push_back(pr[i]); x % pr[i] == 0; x /= pr[i])
        ;
  }
  if (x > 1) g.push_back(x);
}
long long cal(int x, int n, int a, int b) {
  memset(dp, 0x3f, sizeof dp), **dp = 0;
  for (int i = 1; i <= n; ++i) {
    if (c[i] % x == 0) {
      dp[0][i] = dp[0][i - 1];
      dp[2][i] = min(dp[1][i - 1], dp[2][i - 1]);
    } else if ((c[i] + 1) % x == 0 || (c[i] - 1) % x == 0) {
      dp[0][i] = dp[0][i - 1] + b;
      dp[2][i] = min(dp[1][i - 1], dp[2][i - 1]) + b;
    }
    dp[1][i] = min(dp[0][i - 1], dp[1][i - 1]) + a;
  }
  return min(min(dp[0][n], dp[1][n]), dp[2][n]);
}
int main() {
  int i, n, a, b;
  gpr(yuzu), read(n), read(a), read(b);
  for (i = 1; i <= n; ++i) c[i] = read();
  get(c[1] - 1), get(c[1] + 1), get(c[1]);
  get(c[n] - 1), get(c[n] + 1), get(c[n]);
  long long lxy = 1e18;
  for (auto x : g) lxy = min(lxy, cal(x, n, a, b));
  printf("%lld\n", lxy);
}
