#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool getmin(T *a, const T &b) {
  if (b < *a) {
    *a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool getmax(T *a, const T &b) {
  if (b > *a) {
    *a = b;
    return true;
  }
  return false;
}
template <class T>
inline void read(T *a) {
  char c;
  while (isspace(c = getchar())) {
  }
  bool flag = 0;
  if (c == '-')
    flag = 1, *a = 0;
  else
    *a = c - 48;
  while (isdigit(c = getchar())) *a = *a * 10 + c - 48;
  if (flag) *a = -*a;
}
const int mo = 1000000007;
template <class T>
T pow(T a, T b, int c = mo) {
  T res = 1;
  for (T i = 1; i <= b; i <<= 1, a = 1LL * a * a % c)
    if (b & i) res = 1LL * res * a % c;
  return res;
}
const int N = 1200000;
int a[N], n, x, y;
int p[N];
long long tmp[N], tt[N];
long long calc(int p) {
  int l = 0, r = 0;
  int num = 0;
  for (int i = (1); i <= (n); ++i) {
    int x = a[i] % p;
    if ((x > 1 && x < p - 1) && !l) l = i;
    int cost = y;
    if (x == 0) cost = 0;
    tmp[i] = tmp[i - 1] + ::x - cost;
  }
  for (int i = (n); i >= (1); --i) {
    int x = a[i] % p;
    if ((x > 1 && x < p - 1) && !r) r = i;
    int cost = y;
    if (x == 0) cost = 0;
    tt[i] = tt[i + 1] + ::x - cost;
  }
  for (int i = (n - 1); i >= (1); --i) getmax(&tt[i], tt[i + 1]);
  if (!l) {
    long long ans = 0;
    for (int i = (0); i <= (n); ++i) {
      getmax(&ans, tmp[i] + tt[i + 1]);
      if (i) getmax(&ans, tmp[i]);
    }
    return 1LL * n * x - ans;
  }
  long long ans = 0;
  for (int i = (0); i <= (l - 1); ++i) {
    getmax(&ans, tmp[i] + tt[r + 1]);
    if (i) getmax(&ans, tmp[i]);
  }
  return 1LL * n * x - ans;
}
long long solve(int d) {
  if (d == 1) return 1000000000000000000LL;
  int tot = 0;
  int k = d;
  for (int i = 2; i * i <= d; ++i) {
    if (k % i == 0) {
      p[++tot] = i;
      while (k % i == 0) k /= i;
    }
  }
  if (k > 1) p[++tot] = k;
  long long ans = calc(p[1]);
  for (int i = (2); i <= (tot); ++i) getmin(&ans, calc(p[i]));
  return ans;
}
int main() {
  cin >> n >> x >> y;
  for (int i = (1); i <= (n); ++i) read(a + i);
  long long ans = solve(a[1]);
  getmin(&ans, solve(a[1] - 1));
  getmin(&ans, solve(a[1] + 1));
  getmin(&ans, solve(a[n] - 1));
  getmin(&ans, solve(a[n] + 1));
  getmin(&ans, solve(a[n]));
  cout << ans << endl;
  return 0;
}
