#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);
const double eps = (double)1e-9;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
const int N = 1000500;
int n, a[N];
long long x, y, ans, pref[N], suf[N], mn[N];
inline void solve(int pr) {
  for (int i = 1; i <= n; i++) {
    pref[i] = inf;
    if (a[i] % pr == 0) pref[i] = min(pref[i], pref[i - 1]);
    if ((a[i] + 1) % pr == 0) pref[i] = min(pref[i], pref[i - 1] + y);
    if ((a[i] - 1) % pr == 0) pref[i] = min(pref[i], pref[i - 1] + y);
    ans = min(ans, pref[i] + x * (n - i));
  }
  for (int i = n; i >= 1; i--) {
    suf[i] = inf;
    if (a[i] % pr == 0) suf[i] = min(suf[i], suf[i + 1]);
    if ((a[i] + 1) % pr == 0) suf[i] = min(suf[i], suf[i + 1] + y);
    if ((a[i] - 1) % pr == 0) suf[i] = min(suf[i], suf[i + 1] + y);
    ans = min(ans, suf[i] + x * (i - 1));
  }
  mn[n + 1] = inf;
  for (int i = n; i >= 1; i--) {
    suf[i] += x * i;
    mn[i] = min(mn[i + 1], suf[i]);
  }
  for (int i = 1; i <= n; i++)
    ans = min(ans, pref[i] - x * (i + 1) + mn[i + 1]);
}
inline void fact(int num) {
  for (int i = 2; i * i <= num; i++) {
    if (num % i == 0) {
      while (num % i == 0) num /= i;
      solve(i);
    }
  }
  if (num != 1) solve(num);
}
int main() {
  scanf("%d %I64d %I64d", &n, &x, &y);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  ans = inf;
  for (int i = -1; i <= 1; i++) {
    fact(a[1] + i);
    fact(a[n] + i);
  }
  printf("%I64d", ans);
  return 0;
}
