#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int maxm = 1e6 + 5;
const int maxn = 50;
int a[maxm], p[maxn];
int n, A, B, amount;
long long dp[4][maxn], dp1[4][maxn];
long long (*las)[maxn], (*cur)[maxn];
void init() {
  las = dp;
  cur = dp1;
}
void solve1(int x, long long c) {
  for (int i = 2; 1LL * i * i <= x; ++i) {
    if (x % i == 0) {
      las[0][amount] = ~las[0][amount] ? min(las[0][amount], c) : c;
      p[amount++] = i;
      while (x % i == 0) {
        x /= i;
      }
    }
  }
  if (x > 1) {
    las[0][amount] = ~las[0][amount] ? min(las[0][amount], c) : c;
    p[amount++] = x;
  }
}
long long solve() {
  long long ans = INF;
  memset(dp, -1, sizeof(dp));
  amount = 0;
  solve1(a[0], 0);
  solve1(a[0] + 1, B);
  if (a[0] != 2) solve1(a[0] - 1, B);
  for (int i = 1; i < n; ++i) {
    memset(cur, -1, sizeof(dp));
    for (int j = 0; j < amount; ++j) {
      if (~las[0][j])
        cur[1][j] = ~cur[1][j] ? min(las[0][j] + A, cur[1][j]) : las[0][j] + A;
      if (~las[1][j])
        cur[1][j] = ~cur[1][j] ? min(las[1][j] + A, cur[1][j]) : las[1][j] + A;
      if (a[i] % p[j] == 0) {
        if (~las[0][j])
          cur[0][j] = ~cur[0][j] ? min(las[0][j], cur[0][j]) : las[0][j];
        if (~las[1][j])
          cur[2][j] = ~cur[2][j] ? min(las[1][j], cur[2][j]) : las[1][j];
        if (~las[2][j])
          cur[2][j] = ~cur[2][j] ? min(las[2][j], cur[2][j]) : las[2][j];
      } else if ((a[i] + 1) % p[j] == 0 || (a[i] - 1) % p[j] == 0) {
        if (~las[0][j])
          cur[0][j] =
              ~cur[0][j] ? min(las[0][j] + B, cur[0][j]) : las[0][j] + B;
        if (~las[1][j])
          cur[2][j] =
              ~cur[2][j] ? min(las[1][j] + B, cur[2][j]) : las[1][j] + B;
        if (~las[2][j])
          cur[2][j] =
              ~cur[2][j] ? min(las[2][j] + B, cur[2][j]) : las[2][j] + B;
      }
    }
    swap(cur, las);
  }
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < amount; ++j) {
      if (~las[i][j]) {
        ans = min(ans, las[i][j]);
      }
    }
  }
  return ans;
}
int main() {
  init();
  while (~scanf("%d%d%d", &n, &A, &B)) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", &a[i]);
    }
    long long ans = INF;
    ans = min(ans, solve());
    for (int i = 0; i < n / 2; ++i) {
      swap(a[i], a[n - 1 - i]);
    }
    ans = min(ans, solve());
    printf("%I64d\n", ans);
  }
  return 0;
}
