#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-12;
const long long INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000 + 1912;
const int maxn = 1000000 + 1912;
int n, a[maxn];
int x, y;
void ReadData() {
  cin >> n >> x >> y;
  for (int i = 1; i <= n; i++) cin >> a[i];
}
long long dp[maxn][3];
void minimize(long long &a, const long long &b) {
  if (a > b) a = b;
}
long long Solve(int p) {
  long long res = INF;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j < 3; j++) dp[i][j] = INF;
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] % p == 0) {
      minimize(dp[i][0], dp[i - 1][0]);
    }
    if ((a[i] + 1) % p == 0 || (a[i] - 1) % p == 0) {
      minimize(dp[i][0], dp[i - 1][0] + y);
    }
    minimize(dp[i][1], dp[i - 1][1] + x);
    minimize(dp[i][1], dp[i - 1][0] + x);
    if (a[i] % p == 0) {
      minimize(dp[i][2], dp[i - 1][2]);
      minimize(dp[i][2], dp[i - 1][1]);
    }
    if ((a[i] + 1) % p == 0 || (a[i] - 1) % p == 0) {
      minimize(dp[i][2], dp[i - 1][2] + y);
      minimize(dp[i][2], dp[i - 1][1] + y);
    }
  }
  res = min(dp[n][0], min(dp[n][1], dp[n][2]));
  return res;
}
void Process() {
  if (n == 1) {
    int res = 0;
    if (a[1] == 1) res = y;
    cout << res << endl;
    return;
  }
  long long res = 1LL * n * x;
  for (int k = -1; k <= 1; k++) {
    int z = a[1] + k;
    for (int i = 2; i <= sqrt(z); i++) {
      bool ok = (z % i == 0);
      while (z % i == 0) {
        z /= i;
      }
      if (ok) res = min(res, Solve(i));
    }
    if (z > 1) res = min(res, Solve(z));
    z = a[n] + k;
    for (int i = 2; i <= sqrt(z); i++) {
      bool ok = (z % i == 0);
      while (z % i == 0) {
        z /= i;
      }
      if (ok) res = min(res, Solve(i));
    }
    if (z > 1) res = min(res, Solve(z));
  }
  cout << res << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ReadData();
  Process();
}
