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