#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int maxm = 500 * 500 + 10;
const long long inf = 1e15;
const int mod = 20101009;
int getint() {
  char c;
  while ((c = getchar()) && !(c >= '0' && c <= '9') && c != '-')
    ;
  int ret = c - '0', sgn = 0;
  if (c == '-') sgn = 1, ret = 0;
  while ((c = getchar()) && c >= '0' && c <= '9') ret = ret * 10 + c - '0';
  if (sgn) ret = -ret;
  return ret;
}
vector<int> g;
void shai(int n) {
  int m = sqrt(n + 0.5);
  for (int i = 2; i <= m; i++) {
    if (n % i == 0) {
      g.push_back(i);
      while (n % i == 0) n /= i;
    }
  }
  if (n > 1) g.push_back(n);
}
long long lf[maxn], ri[maxn];
int x[maxn];
long long ans;
int n, a, b;
void solve(int p) {
  lf[0] = 0;
  for (int i = 1; i <= n; i++) {
    if (x[i] % p == 0)
      lf[i] = lf[i - 1];
    else if ((x[i] - 1) % p == 0 || (x[i] + 1) % p == 0)
      lf[i] = lf[i - 1] + b;
    else
      lf[i] = inf;
  }
  ri[n + 1] = 0;
  for (int i = n; i >= 1; i--) {
    if (x[i] % p == 0)
      ri[i] = ri[i + 1];
    else if ((x[i] - 1) % p == 0 || (x[i] + 1) % p == 0)
      ri[i] = ri[i + 1] + b;
    else
      ri[i] = inf;
  }
  long long mi = (long long)(n + 1) * a + ri[n + 1];
  for (int i = n; i >= 0; i--) {
    ans = min(ans, lf[i] - (long long)(i + 1) * a + mi);
    mi = min(mi, (long long)i * a + ri[i]);
  }
}
int main() {
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) x[i] = getint();
  g.clear();
  shai(x[1]), shai(x[1] - 1), shai(x[1] + 1), shai(x[n]), shai(x[n] - 1),
      shai(x[n] + 1);
  sort(g.begin(), g.end());
  g.erase(unique(g.begin(), g.end()), g.end());
  int sz = g.size();
  ans = 1e15;
  for (int i = 0; i < sz; i++) {
    solve(g[i]);
  }
  cout << ans << endl;
  return 0;
}
