#include <bits/stdc++.h>
using namespace std;
int q[10000], a[1000010], c[1000010];
long long d[1000010];
int w = 0, m = 0;
void insert(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) {
      q[++w] = i;
      while (x % i == 0) x /= i;
    }
  if (x && x != 1) q[++w] = x;
}
void get_prime(int n) {
  insert(a[1] - 1);
  insert(a[1]);
  insert(a[1] + 1);
  insert(a[n] - 1);
  insert(a[n]);
  insert(a[n] + 1);
  sort(q + 1, q + w + 1);
  for (int i = 1; i <= w; i++)
    if (q[i] != q[m]) q[++m] = q[i];
}
int main() {
  int n, A, B;
  scanf("%d%d%d", &n, &A, &B);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  get_prime(n);
  long long ans = 1e18;
  for (int j = 1; j <= m; j++) {
    int p = q[j], left = n + 1, right = 0;
    bool ok = 1;
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
      int b = a[i] % p;
      if (b > 1 && b < p - 1) {
        left = min(left, i);
        right = max(right, i);
      } else if (b == 0)
        d[i] = 0, c[i] = -A;
      else
        d[i] = B, c[i] = -A + B;
    }
    if (left <= right) {
      if (left == 1 && right == n) continue;
      for (int i = 1; i < left; i++) sum += d[i];
      for (int i = right + 1; i <= n; i++) sum += d[i];
      long long now = 0;
      sum += 1ll * (right - left + 1) * A;
      d[left] = d[right] = 0;
      for (int i = left - 1; i; i--) now += c[i], d[i] = max(now, d[i + 1]);
      now = 0;
      for (int i = right + 1; i <= n; i++)
        now += c[i], d[i] = max(now, d[i - 1]);
      if (left != 1) ans = min(ans, sum - d[2] - d[n]);
      if (right != n) ans = min(ans, sum - d[1] - d[n - 1]);
      continue;
    }
    for (int i = 1; i <= n; i++) sum += d[i];
    long long now = 0, mx = 0;
    for (int i = 1; i < n; i++) {
      now = max(now + c[i], 0ll);
      mx = max(mx, now);
    }
    ans = min(ans, sum - mx);
    now = 0;
    mx = 0;
    for (int i = 2; i <= n; i++) {
      now = max(now + c[i], 0ll);
      mx = max(mx, now);
    }
    ans = min(ans, sum - mx);
  }
  printf("%lld\n", ans);
  return 0;
}
