#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void Read(T &x) {
  int f = 1;
  char t = getchar();
  while (t < '0' || t > '9') {
    if (t == '-') f = -1;
    t = getchar();
  }
  x = 0;
  while (t >= '0' && t <= '9') {
    x = x * 10 + t - '0';
    t = getchar();
  }
  x *= f;
}
template <class T>
inline void chkmin(T &x, T y) {
  if (x > y) x = y;
}
template <class T>
inline void chkmax(T &x, T y) {
  if (x < y) x = y;
}
const int maxn = 1000005;
const int maxpri = 100005;
const long long inf = 0x3f3f3f3f3f3f3f3fll;
int n;
int a;
int b;
int s[maxn];
long long f[maxn][3];
void input() {
  Read(n);
  Read(a);
  Read(b);
  for (int i = 1; i <= n; i++) Read(s[i]);
}
long long calc(int x, int pos) {
  f[0][0] = 0;
  f[0][1] = f[0][2] = inf;
  for (int i = 1; i <= n; i++) {
    f[i][0] = f[i][1] = f[i][2] = inf;
    if (s[i] % x == 0) {
      f[i][0] = f[i - 1][0];
      if (i != pos) f[i][1] = min(f[i - 1][1], f[i - 1][0]) + a;
      f[i][2] = min(f[i - 1][1], f[i - 1][2]);
    } else if (s[i] % x == 1 || s[i] % x == x - 1) {
      f[i][0] = f[i - 1][0] + b;
      if (i != pos) f[i][1] = min(f[i - 1][1], f[i - 1][0]) + a;
      f[i][2] = min(f[i - 1][1], f[i - 1][2]) + b;
    } else {
      if (i != pos) f[i][1] = min(f[i - 1][1], f[i - 1][0]) + a;
    }
  }
  return min(f[n][0], min(f[n][1], f[n][2]));
}
long long getans(int x, int pos) {
  long long res = inf;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      chkmin(res, calc(i, pos));
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) chkmin(res, calc(x, pos));
  return res;
}
void solve() {
  long long ans = inf;
  chkmin(ans, getans(s[1] + 1, 1));
  chkmin(ans, getans(s[1], 1));
  chkmin(ans, getans(s[1] - 1, 1));
  chkmin(ans, getans(s[n] + 1, n));
  chkmin(ans, getans(s[n], n));
  chkmin(ans, getans(s[n] - 1, n));
  cout << ans << endl;
}
int main() {
  input();
  solve();
  return 0;
}
