#include <bits/stdc++.h>
using namespace std;
inline int input() {
  char c;
  int x = 0;
  do {
    c = getchar();
  } while (c <= 32);
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x;
}
const int maxn = 1000100;
int lst, frst, ptr, n, i, j, target;
long long mn, ca, cb, cur, ans;
long long dp[maxn];
long long f[maxn];
long long cost[maxn];
bool can, bad[maxn];
int a[maxn];
int fbad[maxn];
vector<int> v;
inline vector<int> gen(int x) {
  vector<int> ret;
  ret.clear();
  if (x <= 1) return ret;
  int xx = x;
  for (int i = 2; 1ll * i * i <= xx + 5; i++) {
    if (x % i == 0) {
      ret.push_back(i);
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) ret.push_back(x);
  return ret;
}
inline vector<int> merge(vector<int> a, vector<int> b) {
  for (int i = 0; i < (int)b.size(); i++) a.push_back(b[i]);
  return a;
}
int main() {
  n = input(), ca = input(), cb = input();
  for (int i = 1; i <= n; i++) a[i] = input();
  ans = (long long)9e18;
  v.clear();
  for (int i = -1; i <= 1; i++) {
    v = merge(v, gen(a[1] + i));
    v = merge(v, gen(a[n] + i));
  }
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  for (int i = 0; i < (int)v.size(); i++) {
    target = v[i];
    for (int j = 1; j <= n; j++) bad[j] = false;
    for (int j = n; j >= 1; j--) {
      dp[j] = 1ll * cb * min(a[j] % target, target - (a[j] % target));
      if (min(a[j] % target, target - (a[j] % target)) > 1) bad[j] = true;
      if (j < n) dp[j] += dp[j + 1];
    }
    for (int j = 1; j <= n; j++) fbad[j] = fbad[j - 1] + bad[j];
    for (int j = 1; j < n; j++) {
      if (fbad[n] != fbad[j]) continue;
      ans = min(ans, 1ll * ca * j + dp[j + 1]);
    }
  }
  for (int i = 0; i < (int)v.size(); i++) {
    target = v[i];
    for (int j = 1; j <= n; j++) bad[j] = false;
    for (int j = 1; j <= n; j++) {
      dp[j] = 1ll * cb * min(a[j] % target, target - (a[j] % target));
      if (min(a[j] % target, target - (a[j] % target)) > 1) bad[j] = true;
      if (j > 1) dp[j] += dp[j - 1];
    }
    for (int j = 1; j <= n; j++) fbad[j] = fbad[j - 1] + bad[j];
    for (int j = n; j > 1; j--) {
      if (fbad[j - 1] != 0) continue;
      ans = min(ans, 1ll * ca * (n - j + 1) + dp[j - 1]);
    }
  }
  for (int i = 0; i < (int)v.size(); i++) {
    target = v[i];
    cur = 0;
    for (int j = 1; j <= n; j++) bad[j] = false;
    for (int j = 1; j <= n; j++) {
      cost[j] = 1ll * cb * min(a[j] % target, target - (a[j] % target));
      if (min(a[j] % target, target - (a[j] % target)) > 1) bad[j] = true;
      cur += cost[j];
      f[j] = f[j - 1] + ca - cost[j];
    }
    frst = -1;
    for (int j = 1; j <= n; j++) {
      if (bad[j]) {
        frst = j;
        break;
      }
    }
    lst = -1;
    for (int j = n; j >= 1; j--) {
      if (bad[j]) {
        lst = j;
        break;
      }
    }
    mn = (long long)-4e18;
    for (int j = 1; j < n; j++) {
      if (mn != (long long)-4e18 && j >= lst) ans = min(ans, cur + f[j] - mn);
      if (frst == -1 || j < frst) mn = max(mn, f[j]);
    }
  }
  for (int i = 0; i < (int)v.size(); i++) {
    target = v[i];
    can = true;
    cur = 0;
    for (int j = 1; j <= n; j++) {
      if (min(a[j] % target, target - (a[j] % target)) > 1) can = false;
      cur += 1ll * cb * min(a[j] % target, target - (a[j] % target));
    }
    if (can) ans = min(ans, cur);
  }
  cout << ans << endl;
  return 0;
}
