#include <bits/stdc++.h>
using namespace std;
int const N = 1000000 + 2, SQ = sqrt(1e9);
int n, a, b, v[N], id;
map<int, bool> notprime;
vector<int> prms;
map<int, int> fr;
int mx, num;
long long dp[N][4];
long long go(int i, int sit) {
  if (i == n) return 0;
  long long &ret = dp[i][sit];
  if (ret + 1) return ret;
  ret = 1e18;
  if (v[i] % num == 0) {
    if (!sit || sit == 2) ret = min(ret, go(i + 1, sit));
    if (sit == 1) {
      ret = min(ret, go(i + 1, 1) + a);
      ret = min(ret, go(i + 1, 2));
    }
  } else {
    int x = v[i] + 1, y = v[i] - 1;
    if (x % num == 0 || y % num == 0) {
      if (sit == 2) ret = min(ret, go(i + 1, sit) + b);
      if (!sit)
        ret = min(ret, go(i + 1, 1) + a), ret = min(ret, go(i + 1, 0) + b);
      if (sit == 1) {
        ret = min(ret, go(i + 1, 1) + a);
        ret = min(ret, go(i + 1, 2) + b);
      }
    }
    if (x % num && y % num) {
      if (!sit || sit == 1) ret = min(ret, go(i + 1, 1) + a);
    }
  }
  return ret;
}
long long an = 1e18;
void find(int x) {
  if (x == 1) return;
  for (int i = 2; i * i <= x; ++i) {
    if (x % i == 0) {
      num = i;
      memset(dp, -1, sizeof dp);
      an = min(an, go(0, 0));
      while (x % i == 0) x /= i;
    }
  }
  if (x - 1) {
    num = x;
    memset(dp, -1, sizeof dp);
    an = min(an, go(0, 0));
  }
}
int main() {
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 0; i < n; ++i) {
    scanf("%d", v + i);
  }
  find(v[0]);
  find(v[0] + 1);
  find(v[0] - 1);
  find(v[n - 1]);
  find(v[n - 1] + 1);
  find(v[n - 1] - 1);
  cout << an << "\n";
}
