#include <bits/stdc++.h>
using namespace std;
void addmod(int &a, long long b) {
  a = (a + b);
  if (a >= 1000000007) a -= 1000000007;
}
void mulmod(int &a, long long b) { a = (a * b) % 1000000007; }
template <class T>
bool domin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool domax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
int gi() {
  int a;
  scanf("%d", &a);
  return a;
}
long long gll() {
  long long a;
  scanf("%lld", &a);
  return a;
}
set<long long> pf;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void addpf(int x) {
  for (long long i = 2; i * i <= x; i++)
    if (x % i == 0) {
      pf.insert(i);
      while (x % i == 0) x /= i;
    }
  if (x > 1) pf.insert(x);
}
long long doit(int x, const vector<int> &a, const long long &va,
               const long long &vb) {
  int n = a.size();
  int mni = 1000000007, mxi = -1;
  vector<long long> tb(n, 0);
  long long result = 0;
  for (int i = 0; i < n; i++) {
    if (gcd(x, a[i]) > 1)
      continue;
    else if (gcd(x, a[i] - 1) > 1) {
      tb[i] = vb;
    } else if (gcd(x, a[i] + 1) > 1) {
      tb[i] = vb;
    } else {
      mni = min(mni, i);
      mxi = max(mxi, i);
    }
  }
  if (mni == 1000000007) {
    long long tota = 0, mxa = 0, mnb = 0;
    for (int i = 0; i < n; i++) {
      result += tb[i];
      tota += va - tb[i];
      domin(mnb, tota - mxa);
      domax(mxa, tota);
    }
    return result + mnb;
  } else {
    result += va * ((mxi - mni) + 1LL);
    long long tott = 0, mnt = 0, totf = 0, mnf = 0;
    for (int i = mxi + 1; i < n; i++) {
      result += tb[i];
      tott += va - tb[i];
      domin(mnt, tott);
    }
    for (int i = mni - 1; i >= 0; i--) {
      result += tb[i];
      totf += va - tb[i];
      domin(mnf, totf);
    }
    return result + mnf + mnt;
  }
}
int main() {
  int n = gi();
  long long va = gi(), vb = gi();
  vector<int> a(n);
  long long ans = LLONG_MAX;
  for (auto i = 0; i < n; i++) {
    a[i] = gi();
  }
  for (int i = -1; i < 2; i++) {
    addpf(a[0] + i);
    addpf(a[n - 1] + i);
  }
  for (auto i : pf) {
    domin(ans, doit(i, a, va, vb));
  }
  cout << ans << endl;
  return 0;
}
