#include <bits/stdc++.h>
using namespace std;
long long ans = (long long)1 << 59;
long long _Min(long long x, long long y) { return x < y ? x : y; }
int A[1000010], n, a, b;
int t[1000010];
void check(int x) {
  int i, L = n + 1, R = 0, l = 0;
  long long s = 0, sum = 0, ss = 0;
  for (i = 1; i <= n; i++) {
    if (A[i] % x == 0)
      t[i] = 0;
    else if ((A[i] - 1) % x == 0 || (A[i] + 1) % x == 0)
      t[i] = 1;
    else {
      t[i] = 2;
      if (L > i) L = i;
      R = i;
    }
  }
  for (i = R; i <= n; i++) ss += t[i] * b;
  for (i = R; i <= n; i++) {
    ss -= t[i] * b;
    while (l < L && l <= i) {
      s = _Min(s, sum);
      l++;
      sum += t[l] * b - a;
    }
    ans = _Min(ans, (long long)a * i + s + ss);
  }
}
void make(int x) {
  int i;
  for (i = 2; i * i <= x; i++)
    if (x % i == 0) {
      check(i);
      while (x % i == 0) x /= i;
    }
  if (x != 1) check(x);
}
int main() {
  int i, j;
  scanf("%d%d%d", &n, &a, &b);
  for (i = 1; i <= n; i++) scanf("%d", &A[i]);
  make(A[1] - 1);
  make(A[1]);
  make(A[1] + 1);
  make(A[n] - 1);
  make(A[n]);
  make(A[n] + 1);
  printf("%I64d\n", ans);
  return 0;
}
