#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000100;
const int INF = 1e9 + 10;
const long long MAX = 1e18 + 10;
int n;
long long a, b;
long long x[maxn], f[maxn], g[maxn];
vector<long long> prime;
bool isprime[maxn];
set<long long> s;
void getPrime() {
  int i, j;
  memset(isprime, 1, sizeof(isprime));
  isprime[1] = 0;
  for (i = 2; i < maxn; i++) {
    if (!isprime[i]) continue;
    for (j = i + i; j < maxn; j += i) isprime[j] = 0;
  }
  for (i = 2; i < maxn; i++)
    if (isprime[i]) prime.push_back(i);
}
long long change(long long x, long long p) {
  if (x % p == 0) return 0;
  if ((x - 1) % p == 0 || (x + 1) % p == 0) return b;
  return -1;
}
long long solve(long long p) {
  int L = n + 1, R = 0, i;
  f[0] = 0;
  int tag = 0;
  for (i = 1; i <= n; i++) {
    long long t = change(x[i], p);
    if (t == -1) {
      L = i;
      tag = 1;
    }
    if (tag)
      f[i] = MAX;
    else
      f[i] = f[i - 1] + t;
  }
  g[n + 1] = 0;
  tag = 0;
  for (i = n; i >= 1; i--) {
    long long t = change(x[i], p);
    if (t == -1) {
      R = i;
      tag = 1;
    }
    if (tag)
      g[i] = MAX;
    else
      g[i] = g[i + 1] + t;
  }
  long long G = g[n + 1] + (n + 1) * a;
  long long res = f[n];
  for (i = n; i >= 0; i--) {
    res = min(res, f[i] - (i + 1) * a + G);
    G = min(G, g[i] + i * a);
  }
  return res;
}
void get(long long x) {
  if (x == 0 || x == 1) return;
  for (int i = 0; i < prime.size(); i++) {
    long long t = prime[i];
    if (t * t > x) break;
    if (x % t == 0) {
      s.insert(t);
      while (x % t == 0) x /= t;
    }
  }
  if (x > 1) s.insert(x);
}
void Init() {
  s.clear();
  get(x[1]);
  get(x[1] + 1);
  get(x[1] - 1);
  get(x[n]);
  get(x[n] + 1);
  get(x[n] - 1);
}
int main() {
  int i;
  getPrime();
  while (cin >> n >> a >> b) {
    for (i = 1; i <= n; i++) scanf("%I64d", &x[i]);
    Init();
    long long ans = MAX;
    for (set<long long>::iterator it = s.begin(); it != s.end(); ++it)
      ans = min(ans, solve(*it));
    cout << ans << endl;
  }
  return 0;
}
