#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;
const int ub = 1e6;
const double inf = 1e-4;
long long powmod(long long x, long long y) {
  long long t;
  for (t = 1; y; y >>= 1, x = x * x % mod)
    if (y & 1) t = t * x % mod;
  return t;
}
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
int n, a, b, x;
int seq[maxn];
long long dp[maxn][3], val[maxn], INF;
long long solve(int fac) {
  INF = 1e18;
  long long ans = INF;
  for (int(i) = (1); (i) < (n + 1); (i)++)
    if (seq[i] % fac == 0)
      val[i] = 0;
    else if ((seq[i] + 1) % fac == 0 || (seq[i] - 1) % fac == 0)
      val[i] = b;
    else
      val[i] = INF;
  dp[0][0] = dp[0][1] = dp[0][2] = 0;
  for (int(i) = (1); (i) < (n + 1); (i)++) {
    dp[i][0] = dp[i - 1][0] + val[i];
    dp[i][0] = min(dp[i][0], INF);
    dp[i][1] = min(dp[i - 1][1], dp[i - 1][0]) + a;
    dp[i][1] = min(dp[i][1], INF);
    dp[i][2] = min(dp[i - 1][2], dp[i - 1][1]) + val[i];
    dp[i][2] = min(dp[i][2], INF);
  }
  return min(min(dp[n][0], dp[n][1]), dp[n][2]);
}
int f[maxn / 10], cnt = 0;
void divid(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) {
      while (x % i == 0) x /= i;
      f[cnt++] = i;
    }
  if (x > 1) f[cnt++] = x;
}
int main() {
  cin >> n >> a >> b;
  for (int(i) = (1); (i) < (n + 1); (i)++) cin >> seq[i];
  divid(seq[1] + 1), divid(seq[1] - 1), divid(seq[1]);
  divid(seq[n] + 1), divid(seq[n] - 1), divid(seq[n]);
  sort(f, f + cnt);
  cnt = unique(f, f + cnt) - f;
  long long ans = 1e18;
  for (int(i) = (0); (i) < (cnt); (i)++) ans = min(ans, solve(f[i]));
  cout << ans << endl;
  return 0;
}
