#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const long long INF = 1e15;
vector<int> primes;
int n, ca, cb, a[N];
long long int ans = INF, dp[2][100][3];
long long int cost(int x, int y) {
  if (x % y == 0) return 0;
  if ((x + 1) % y == 0 || (x - 1) % y == 0) return 1;
  return INF;
}
void get_prime(int x) {
  int temp = x;
  for (int i = 2; i * i <= temp; i++) {
    if (x % i == 0) {
      while (x % i == 0) x /= i;
      primes.push_back(i);
    }
  }
  if (x != 1) primes.push_back(x);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> ca >> cb;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = -1; i <= 1; i++) {
    get_prime(a[1] + i);
    get_prime(a[n] + i);
  }
  sort(primes.begin(), primes.end());
  primes.resize(unique(primes.begin(), primes.end()) - primes.begin());
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 100; j++)
      for (int k = 0; k < 3; k++) dp[i][j][k] = INF;
  for (int i = 0; i < primes.size(); i++)
    dp[0][i][0] = dp[0][i][1] = dp[0][i][2] = 0;
  for (int i = 1; i <= n; i++) {
    int cur = i & 1, lst = !(i & 1);
    for (int j = 0; j < primes.size(); j++) {
      if (dp[lst][j][0] < INF && cost(a[i], primes[j]) < INF)
        dp[cur][j][0] =
            min(dp[cur][j][0], dp[lst][j][0] + cb * cost(a[i], primes[j]));
      if (dp[lst][j][0] < INF)
        dp[cur][j][1] = min(dp[cur][j][1], dp[lst][j][0] + ca);
      if (dp[lst][j][1] < INF)
        dp[cur][j][1] = min(dp[cur][j][1], dp[lst][j][1] + ca);
      if (dp[lst][j][1] < INF && cost(a[i], primes[j]) < INF)
        dp[cur][j][2] =
            min(dp[cur][j][2], dp[lst][j][1] + cb * cost(a[i], primes[j]));
      if (dp[lst][j][1] < INF && cost(a[i], primes[j]) < INF)
        dp[cur][j][2] =
            min(dp[cur][j][2], dp[lst][j][2] + cb * cost(a[i], primes[j]));
    }
    for (int j = 0; j < primes.size(); j++)
      for (int k = 0; k < 3; k++) dp[lst][j][k] = INF;
  }
  for (int j = 0; j < primes.size(); j++)
    for (int k = 0; k < 3; k++) ans = min(ans, dp[n & 1][j][k]);
  cout << ans << endl;
}
