#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
const long long inf = 1000000000000000000LL;
int a[N];
long long prefix_cost[N], cost[N], suffix_cost[N];
set<int> factors;
set<int>::iterator it;
void pf(int x) {
  for (int j = x - 1; j <= x + 1; j++) {
    int d = j;
    for (int i = 2; i * i <= j; i++) {
      if (d % i == 0) {
        factors.insert(i);
        while (d % i == 0) d /= i;
      }
    }
    if (d != 1) factors.insert(d);
  }
}
int main() {
  int n, p, A, B;
  scanf("%d %d %d", &n, &A, &B);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  if (n == 1) {
    printf("0\n");
    return 0;
  }
  pf(a[1]);
  pf(a[n]);
  long long ans = inf;
  for (it = factors.begin(); it != factors.end(); ++it) {
    prefix_cost[0] = 0LL;
    p = *it;
    for (int i = 1; i <= n; i++) {
      if (a[i] % p == 0)
        cost[i] = 0LL;
      else if ((a[i] + 1) % p == 0 || (a[i] - 1) % p == 0)
        cost[i] = (long long)B;
      else
        cost[i] = inf;
      prefix_cost[i] = prefix_cost[i - 1] + cost[i];
      if (prefix_cost[i] > inf) prefix_cost[i] = inf;
    }
    prefix_cost[0] = inf;
    suffix_cost[n + 1] = 0LL;
    long long suffix_sum = 0LL;
    for (int i = n; i > 0; i--) {
      suffix_sum += cost[i];
      if (suffix_sum > inf) suffix_sum = inf;
      suffix_cost[i] = min(A + suffix_cost[i + 1], suffix_sum);
    }
    ans = min(ans, suffix_cost[1]);
    for (int i = 2; i <= n; i++)
      ans = min(ans, prefix_cost[i - 1] + suffix_cost[i]);
  }
  printf("%I64d\n", ans);
  return 0;
}
