#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
inline bool Min(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
inline bool Max(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
inline int ni() {
  int a;
  scanf("%d", &a);
  return a;
}
inline ll nl() {
  ll a;
  scanf("%lld", &a);
  return a;
}
inline double nd() {
  double a;
  scanf("%lf", &a);
  return a;
}
inline void pi(int a) { printf("%d ", a); }
inline void pl(ll a) { printf("%lld ", a); }
inline void pd(double a) { printf("%.12lf ", a); }
const int N = 1e6 + 10;
int xs[N];
ll A, B;
int n;
vector<int> primes;
vector<int> to_check;
ll dp_pref[N], dp_suff_min[N];
ll dp_suff[N], dp_pref_min[N];
ll ans = INT64_MAX;
vector<char> GetPrimeVector(int n) {
  vector<char> ans(n + 1, true);
  ans[1] = false;
  for (int i = 2; i * i <= n; i++)
    if (ans[i])
      for (int j = i * i; j <= n; j += i) ans[j] = false;
  return ans;
}
bool is_prime(int x) {
  for (auto pr : primes) {
    if (pr * pr > x) break;
    if (x % pr == 0) return false;
  }
  return true;
}
void addToCheck(int x) {
  for (int i = 1; i * i <= x; i++) {
    if (x % i) continue;
    if (is_prime(i)) to_check.push_back(i);
    if (is_prime(x / i)) to_check.push_back(x / i);
  }
}
void precalc() {
  auto pr = GetPrimeVector(5e4);
  for (int i = (int)(2); i <= (int)(pr.size() - 1); ++i)
    if (pr[i]) primes.push_back(i);
  for (int i = (int)(xs[1] - 1); i <= (int)(xs[1] + 1); ++i) addToCheck(i);
  for (int i = (int)(xs[n] - 1); i <= (int)(xs[n] + 1); ++i) addToCheck(i);
  sort((to_check).begin(), (to_check).end());
  to_check.resize(unique((to_check).begin(), (to_check).end()) -
                  to_check.begin());
}
void solve() {
  n = ni();
  A = nl();
  B = nl();
  for (int i = 1; i < (int)(n + 1); ++i) xs[i] = ni();
  precalc();
  for (int gc : to_check) {
    if (gc < 2) continue;
    dp_pref[0] = dp_suff[n + 1] = 0;
    for (int i = 1; i <= n; i++) {
      dp_pref[i] = dp_pref[i - 1];
      if (xs[i] % gc == 0)
        dp_pref[i] += 0;
      else if (((xs[i] + 1) % gc == 0) or ((xs[i] - 1) % gc == 0))
        dp_pref[i] += B;
      else
        dp_pref[i] = 1e18;
    }
    for (int i = n; i >= 1; i--) {
      dp_suff[i] = dp_suff[i + 1];
      if (xs[i] % gc == 0)
        dp_suff[i] += 0;
      else if (((xs[i] + 1) % gc == 0) or ((xs[i] - 1) % gc == 0))
        dp_suff[i] += B;
      else
        dp_suff[i] = 1e18;
    }
    for (int i = 0; i <= n + 1; i++)
      dp_suff_min[i] = dp_suff[i], dp_pref_min[i] = dp_pref[i];
    for (int i = n + 1; i >= 0; i--)
      if (dp_suff[i] < 1e18) dp_suff_min[i] += A * (i - 1);
    for (int i = n; i >= 0; i--) Min(dp_suff_min[i], dp_suff_min[i + 1]);
    for (int i = 0; i <= n; i++)
      if (dp_pref[i] < 1e18) dp_pref_min[i] += A * (n - i);
    for (int i = 1; i <= n; i++) Min(dp_pref_min[i], dp_pref_min[i - 1]);
    for (int i = 1; i <= n; i++)
      if (dp_pref[i] < 1e18)
        Min(ans, dp_pref[i] - A * (i) + dp_suff_min[i + 1]);
    for (int i = 1; i <= n; i++)
      if (dp_suff[i] < 1e18)
        Min(ans, dp_suff[i] - A * (n - i + 1) + dp_pref_min[i - 1]);
  }
  pl(ans);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
