#include <bits/stdc++.h>
using namespace std;
long long a, b, Dp[1000010][3], Ans = 1e17;
int n, A[1000010], c[10];
long long calc(int x, int M) {
  if (x % M == 0) return 0;
  if ((x + 1) % M == 0 || ((x - 1) % M == 0 && x >= 2)) return b;
  return 1e17;
}
long long work(int M) {
  for (int i = 1; i <= n; i++) {
    Dp[i][0] = 1e17;
    Dp[i][1] = 1e17;
    Dp[i][2] = 1e17;
    Dp[i][0] = Dp[i - 1][0] + calc(A[i], M);
    Dp[i][1] = min(Dp[i - 1][1], Dp[i - 1][0]) + a;
    Dp[i][2] = min(Dp[i - 1][1], Dp[i - 1][2]) + calc(A[i], M);
    Dp[i][0] = (Dp[i][0] > 1e17) ? 1e17 : Dp[i][0];
    Dp[i][1] = (Dp[i][1] > 1e17) ? 1e17 : Dp[i][1];
    Dp[i][2] = (Dp[i][2] > 1e17) ? 1e17 : Dp[i][2];
  }
  long long ret = 1e17;
  ret = min(ret, min(Dp[n][0], Dp[n][2]));
  if (Dp[n][1] != n * a) ret = min(ret, Dp[n][1]);
  return ret;
}
int main() {
  scanf("%d", &n);
  scanf("%I64d%I64d", &a, &b);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
  c[1] = A[1];
  c[2] = A[n];
  c[3] = A[1] - 1;
  c[4] = A[1] + 1;
  c[5] = A[n] - 1;
  c[6] = A[n] + 1;
  for (int i = 1; i <= 6; i++) {
    for (int p = 2; p * p <= c[i]; p++) {
      if (c[i] % p == 0) {
        while (c[i] % p == 0) c[i] /= p;
        Ans = min(Ans, work(p));
      }
    }
    if (c[i] != 1) Ans = min(Ans, work(c[i]));
  }
  printf("%I64d", Ans);
}
