#include <bits/stdc++.h>
inline long long read() {
  long long res = 0, bo = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') bo = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    res = (res << 1) + (res << 3) + ch - '0';
    ch = getchar();
  }
  return bo * res;
}
template <typename T>
void read(T &x) {
  x = read();
}
template <typename T, typename... Argv>
void read(T &a, Argv &...argv) {
  read(a);
  read(argv...);
}
const int N = 1e6 + 10;
long long a[N], A, B, n;
std::vector<int> p;
long long f[N][3], val[N];
void init(int n) {
  int x = n;
  for (int i = 2; i * i <= n; ++i) {
    if (x % i == 0) {
      p.push_back(i);
      while (x % i == 0) x /= i;
    }
  }
  if (x != 1) p.push_back(x);
}
long long Calc(int p) {
  for (int i = 1; i <= n; ++i) {
    if (a[i] % p == 0)
      val[i] = 0;
    else if (((a[i] + 1) % p == 0) || ((a[i] - 1) % p == 0))
      val[i] = B;
    else
      val[i] = -1;
  }
  memset(f, 0, sizeof(f));
  for (int i = 1; i <= n; ++i) {
    if (val[i] < 0) {
      f[i][0] = f[i][2] = 1e18;
      f[i][1] = std::min(f[i - 1][1], f[i - 1][0]) + A;
    } else {
      f[i][0] = f[i - 1][0] + val[i];
      f[i][1] = std::min(f[i - 1][1], f[i - 1][0]) + A;
      f[i][2] = std::min(f[i - 1][1], f[i - 1][2]) + val[i];
    }
  }
  return std::min(f[n][0], std::min(f[n][1], f[n][2]));
}
int main() {
  n = read();
  A = read(), B = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  init(a[1]), init(a[1] - 1), init(a[1] + 1);
  init(a[n]), init(a[n] - 1), init(a[n] + 1);
  std::sort(p.begin(), p.end());
  int tot = std::unique(p.begin(), p.end()) - p.begin();
  long long ans = (n - 1) * A;
  for (int i = 0; i < tot; ++i) ans = std::min(ans, Calc(p[i]));
  std::cout << ans << std::endl;
  return 0;
}
