#include <bits/stdc++.h>
using namespace std;
int n, *x;
long long a, b;
long long solve(int d) {
  char* type = new char[n];
  vector<int> pos;
  for (int i = 0; i < n; i++) {
    if (x[i] % d == 0)
      type[i] = 0;
    else if ((x[i] - 1) % d == 0 || (x[i] + 1) % d == 0)
      type[i] = 1;
    else
      type[i] = 2;
    if (type[i] > 0) pos.push_back(i);
  }
  if (pos.empty()) return 0;
  if (pos.size() == 1) {
    if (type[pos[0]] == 1)
      return min(a, b);
    else
      return a;
  }
  long long dd = 0, dl = 0;
  bool good = 1;
  vector<long long> left;
  left.resize(pos.size());
  for (int i = 0; i < pos.size() - 1; i++) {
    if (type[pos[i]] == 2) good = 0;
    if (type[pos[i]] == 1 && good) dd += -(pos[i + 1] - pos[i]) * a + b;
    dl = min(dl, dd);
    left[i] = dl;
  }
  if (type[pos.back()] == 1 && good) {
    dd += -a + b;
    dl = min(dl, dd);
    left[pos.size() - 1] = dl;
  }
  dd = 0;
  long long dr = 0;
  good = 1;
  vector<long long> right;
  right.resize(pos.size());
  for (int i = pos.size() - 1; i > 0; i--) {
    if (type[pos[i]] == 2) good = 0;
    if (type[pos[i]] == 1 && good) dd += -(pos[i] - pos[i - 1]) * a + b;
    dr = min(dr, dd);
    right[i] = dr;
  }
  if (type[pos[0]] == 1 && good) {
    dd += -a + b;
    dr = min(dr, dd);
    right[0] = dr;
  }
  long long cost = (pos.back() - pos[0] + 1) * a;
  dd = min(0ll, right[1]);
  right.push_back(0);
  right.push_back(0);
  for (int i = 0; i < pos.size(); i++) dd = min(dd, left[i] + right[i + 2]);
  cost += dd;
  delete[] type;
  return cost;
}
int main() {
  scanf("%d%I64d%I64d", &n, &a, &b);
  x = new int[n];
  for (int i = 0; i < n; i++) scanf("%d", x + i);
  int y[6] = {x[0], x[0] - 1, x[0] + 1, x[n - 1], x[n - 1] - 1, x[n - 1] + 1};
  long long pen[6] = {0, b, b, 0, b, b};
  long long ssol = max(n * b, n * a) + 10;
  int* x0 = x;
  int n0 = n;
  for (int i = 0; i < 6; i++) {
    if (i == 1 || i == 2) {
      n = n - 1;
      x += 1;
    } else if (i == 4 || i == 5) {
      n = n - 1;
    }
    for (int d = 2; d * d <= y[i]; d++) {
      if (y[i] % d == 0) ssol = min(ssol, solve(d) + pen[i]);
      while (y[i] % d == 0) y[i] /= d;
    }
    if (y[i] > 1) ssol = min(ssol, solve(y[i]) + pen[i]);
    n = n0;
    x = x0;
  }
  printf("%I64d", ssol);
}
