#include <bits/stdc++.h>
using namespace std;
int n, A, B, P;
int a[1000011];
long long dp[1000011][3];
vector<long long> f(int x) {
  vector<long long> res;
  int y = 2;
  while (y * y <= x) {
    if (x % y == 0) res.push_back(y);
    while (x % y == 0) x /= y;
    y++;
  }
  if (x != 1) res.push_back(x);
  return res;
}
long long solve(int pos, int st) {
  if (pos == n) return 0;
  long long &ret = dp[pos][st];
  if (ret != -1) return ret;
  ret = 1ll << 60;
  if (st == 0) {
    ret = min(ret, B + solve(pos + 1, 1));
    if (a[pos] % P == 0)
      ret = min(ret, solve(pos + 1, 0));
    else if ((a[pos] + 1) % P == 0 || (a[pos] - 1) % P == 0)
      ret = min(ret, A + solve(pos + 1, 0));
  } else if (st == 1) {
    ret = min(ret, B + solve(pos + 1, 1));
    if (a[pos] % P == 0)
      ret = min(ret, solve(pos + 1, 2));
    else if ((a[pos] + 1) % P == 0 || (a[pos] - 1) % P == 0)
      ret = min(ret, A + solve(pos + 1, 2));
  } else {
    if (a[pos] % P == 0)
      ret = min(ret, solve(pos + 1, 2));
    else if ((a[pos] + 1) % P == 0 || (a[pos] - 1) % P == 0)
      ret = min(ret, A + solve(pos + 1, 2));
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  scanf("%d", &B);
  scanf("%d", &A);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  long long res = 1ll << 60;
  for (int N = 0; N < 2; N++) {
    for (int K = 0; K < 3; K++) {
      vector<long long> prim = f(a[0] + K - 1);
      for (int i = 0; i < prim.size(); i++) {
        memset(dp, -1, sizeof dp);
        long long temp = 0;
        if (K != 1) temp += A;
        P = prim[i];
        temp += solve(1, 0);
        res = min(res, temp);
      }
    }
    reverse(a, a + n);
  }
  cout << res << endl;
  return 0;
}
