#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const long long INF = 1e16;
int abs(int x) { return x > 0 ? x : -x; }
void primeDiv(int a, vector<int>& p) {
  p.clear();
  for (int i = 2; i * i <= a; ++i) {
    if (a % i == 0) {
      p.push_back(i);
      while (a % i == 0) a /= i;
    }
  }
  if (a > 1) p.push_back(a);
}
int n, a[N];
long long x, y, dp[N][3];
bool check(int x, int p) {
  bool ok = false;
  for (int d = -1; d <= 1; ++d) ok |= ((x + d) % p == 0);
  return ok;
}
long long solve(int p) {
  for (int i = 0; i < 3; ++i) dp[0][i] = 0;
  for (int i = 1; i <= n; ++i) {
    dp[i][1] = min(dp[i - 1][1], dp[i - 1][0]) + x;
    if (!check(a[i - 1], p))
      dp[i][0] = dp[i][2] = INF;
    else {
      dp[i][0] = dp[i - 1][0] + y * (a[i - 1] % p != 0);
      dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]) + y * (a[i - 1] % p != 0);
    }
  }
  long long res = INF;
  for (int i = 0; i < 3; ++i) res = min(res, dp[n][i]);
  return res;
}
int main() {
  scanf("%d%I64d%I64d", &n, &x, &y);
  for (int* it = a; it < a + n; ++it) scanf("%d", it);
  long long ans = INF;
  vector<int> prime;
  for (int d = -1; d <= 1; ++d) {
    primeDiv(a[0] + d, prime);
    for (int p : prime) ans = min(ans, solve(p));
  }
  for (int d = -1; d <= 1; ++d) {
    primeDiv(a[n - 1] + d, prime);
    for (int p : prime) ans = min(ans, solve(p));
  }
  printf("%I64d", ans);
}
