#include <bits/stdc++.h>
using namespace std;
long long modpow(long long a, long long b,
                 long long mod = (long long)(1e9 + 7)) {
  if (!b) return 1;
  a %= mod;
  return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mxn = 1e6;
const long long infty = 1e18;
int n, a, b, p;
int x[mxn];
vector<int> primes;
long long dp[mxn][3];
long long cost(int i) {
  return x[i] % p ? (x[i] % p == 1 || x[i] % p + 1 == p ? b : infty) : 0;
}
long long dpsolve() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 3; j++) dp[i][j] = infty;
  dp[0][0] = dp[0][2] = cost(0);
  dp[0][1] = a;
  for (int i = 0; i < n - 1; i++)
    for (int j = 0; j < 3; j++)
      if (dp[i][j] < infty)
        for (int k = j; k <= 2; k++) {
          if (k == 1)
            (dp[i + 1][k]) = min((dp[i + 1][k]), (dp[i][j] + a));
          else
            (dp[i + 1][k]) = min((dp[i + 1][k]), (dp[i][j] + cost(i + 1)));
        }
  long long ans = infty;
  for (int k = 0; k < 3; k++) (ans) = min((ans), (dp[n - 1][k]));
  return ans;
}
inline void getPrime(int temp) {
  for (long long p = 2; p * p <= temp; p++)
    if (temp % p == 0) {
      primes.push_back(p);
      while (temp % p == 0) temp /= p;
    }
  if (temp > 1) primes.push_back(temp);
}
void solve() {
  scanf("%d", &n);
  scanf("%d", &a);
  scanf("%d", &b);
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  for (int d = -1; d <= 1; d++) getPrime(x[0] + d), getPrime(x[n - 1] + d);
  long long ans = infty;
  for (int pp : primes) p = pp, (ans) = min((ans), (dpsolve()));
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
