#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000030;
const long long MODD = 1000000009;
int A[MAX_N];
long long B[MAX_N][2];
long long n, a, b;
long long f(long long x) {
  B[0][0] = B[0][1] = 0;
  int m = 0, f = 0;
  for (int i = 0; i < n; i++) {
    int val = -1;
    for (int k = -1; k <= 1; k++)
      if ((A[i] + k) % x == 0) {
        val = (k ? 1 : 0);
        break;
      }
    B[i + 1][0] = B[i + 1][1] = min(B[i][0], B[i][1]) + a;
    if (val == -1) f = 1;
    if (!f) {
      B[i + 1][0] = B[i][0] + val * b;
      m++;
    }
  }
  long long best = min(B[n][0], B[n][1]);
  f = 0;
  long long E = 0;
  for (int i = n - 1; i >= 0; i--) {
    int val = -1;
    for (int k = -1; k <= 1; k++)
      if ((A[i] + k) % x == 0) {
        val = (k != 0);
        break;
      }
    if (val == -1) {
      break;
    }
    E += val * b;
    if (i < m) best = min(best, E + B[i][0]);
    best = min(best, E + B[i][1]);
  }
  return best;
}
void do_case() {
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) cin >> A[i];
  if (n == 1) {
    cout << 0 << endl;
    return;
  }
  vector<long long> facs;
  for (int j = 0; j < n; j += n - 1) {
    for (int k = A[j] - 1; k <= A[j] + 1; k++) {
      long long x = k;
      for (long long i = 2; i * i <= x; i++) {
        if (x % i == 0) {
          facs.push_back(i);
          while (x % i == 0) x /= i;
        }
      }
      if (x > 1) facs.push_back(x);
    }
  }
  sort(facs.begin(), facs.end());
  facs.resize(unique(facs.begin(), facs.end()) - facs.begin());
  long long ans = -1;
  for (long long x : facs) {
    long long val = f(x);
    if (ans == -1 || val < ans) ans = val;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  do_case();
  return 0;
}
