#include <bits/stdc++.h>
using namespace std;
template <class T>
T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <class T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
template <class T>
void read(vector<T> &v) {
  T x;
  cin >> x;
  v.push_back(x);
}
int n, a, b, x[1000005];
long long ans = (long long)1000000007 * 1000000007, f[1000005][3];
bool isPrime(int n) {
  if (n < 2) return false;
  int lim = sqrt(n);
  for (int i = (2); i <= (lim); ++i) {
    if (n % i == 0) return false;
  }
  return true;
}
void Solve(int p) {
  if (!isPrime(p)) return;
  for (int i = (0); i <= (n); ++i) {
    for (int k = (0); k <= (2); ++k)
      f[i][k] = (long long)1000000007 * 1000000007;
  }
  f[0][0] = 0;
  for (int i = (1); i <= (n); ++i) {
    if (x[i] % p == 0) {
      f[i][0] = f[i - 1][0];
      f[i][2] = min(f[i - 1][1], f[i - 1][2]);
    } else if ((x[i] - 1) % p == 0 || (x[i] + 1) % p == 0) {
      f[i][0] = f[i - 1][0] + b;
      f[i][2] = min(f[i - 1][1], f[i - 1][2]) + b;
    }
    f[i][1] = min(f[i - 1][0], f[i - 1][1]) + a;
  }
  for (int k = (0); k <= (2); ++k) ans = min(ans, f[n][k]);
}
void Try(int p) {
  int lim = sqrt(p);
  for (int i = (1); i <= (lim); ++i) {
    if (p % i == 0) {
      Solve(i);
      Solve(p / i);
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &a, &b);
  for (int i = (1); i <= (n); ++i) scanf("%d", &x[i]);
  for (int d = (-1); d <= (1); ++d) {
    Try(x[1] + d);
    Try(x[n] + d);
  }
  cout << ans;
  return 0;
}
