#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e15 + 1;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;
long long n, f[maxn][3], a, b, s[maxn], res(+oo);
void Check(int x, int w) {
  f[1][0] = f[1][1] = f[1][2] = w;
  for (int i = 2; i <= n; ++i) {
    f[i][0] = f[i - 1][0];
    f[i][2] = f[i - 1][2];
    if (s[i] % x != 0) {
      if ((s[i] - 1) % x == 0 || (s[i] + 1) % x == 0)
        f[i][0] += b, f[i][2] += b;
      else
        f[i][0] = +oo, f[i][2] = +oo;
    }
    f[i][1] = min(f[i - 1][1], f[i - 1][0]) + a;
    f[i][2] = min(f[i][2], f[i][1]);
  }
  res = min(res, min(f[n][0], min(f[n][1], f[n][2])));
}
void Factorize(int x, int w) {
  if (x <= 1) return;
  for (int i = 2; i * i <= x; ++i)
    if (x % i == 0) {
      while (x % i == 0) x /= i;
      Check(i, w);
    }
  if (x != 1) Check(x, w);
}
void Init() {
  cin >> n >> a >> b;
  for (int i = 1; i <= n; ++i) cin >> s[i];
  Factorize(s[1] - 1, b);
  Factorize(s[1], 0);
  Factorize(s[1] + 1, b);
  for (int i = 1; i <= n / 2 + 1; ++i) swap(s[i], s[n + 1 - i]);
  Factorize(s[1] - 1, b);
  Factorize(s[1], 0);
  Factorize(s[1] + 1, b);
  Check(5, b);
  cout << res;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  Init();
}
