#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e6 + 3;
const long long inf = 1e15;
long long v[nmax], k, t[93], n, a, b, d[nmax][3], sol, p;
void divizor(long long usu) {
  for (long long i = 2; i * i <= usu; ++i) {
    if (usu % i == 0) {
      t[++k] = i;
      while (usu % i == 0) usu /= i;
    }
  }
  if (usu > 1) t[++k] = usu;
}
void clean() {
  for (int i = 1; i <= n; ++i) {
    d[i][0] = inf;
    d[i][1] = inf;
    d[i][2] = inf;
  }
}
void solve() {
  divizor(v[1]);
  divizor(v[1] - 1);
  divizor(v[1] + 1);
  divizor(v[n]);
  divizor(v[n] - 1);
  divizor(v[n] + 1);
  sort(t + 1, t + k + 1);
  sol = inf;
  for (int i = 1; i <= k; ++i) {
    clean();
    if (t[i] == t[i - 1]) continue;
    p = t[i];
    for (int j = 1; j <= n; ++j) {
      if (v[j] % p == 0) {
        d[j][0] = d[j - 1][0];
        d[j][1] = min(d[j - 1][0] + a, d[j - 1][1] + a);
        d[j][2] = min(d[j - 1][1], d[j - 1][2]);
        continue;
      }
      if ((v[j] - 1) % p == 0 || (v[j] + 1) % p == 0) {
        d[j][0] = d[j - 1][0] + b;
        d[j][1] = min(d[j - 1][0] + a, d[j - 1][1] + a);
        d[j][2] = min(d[j - 1][1] + b, d[j - 1][2] + b);
        continue;
      }
      d[j][1] = min(d[j - 1][0] + a, d[j - 1][1] + a);
    }
    sol = min(min(sol, d[n][0]), min(d[n][1], d[n][2]));
  }
}
int main() {
  cin >> n >> a >> b;
  for (int i = 1; i <= n; ++i) cin >> v[i];
  solve();
  cout << sol;
  return 0;
}
