#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int c[N];
long long a, b;
vector<int> d;
void div(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      d.push_back(i);
      while (n % i == 0) n /= i;
    }
  }
  if (n > 1) d.push_back(n);
}
void f(int n) {
  div(n);
  div(n - 1);
  div(n + 1);
}
long long L[N], R[N];
const long long inf = 1LL << 60;
long long ans = 1LL << 60;
long long sol(int fac, int n) {
  long long ans = inf;
  L[0] = 0;
  for (int i = 1; i <= n; i++) {
    L[i] = inf;
    if (c[i] % fac == 0)
      L[i] = L[i - 1];
    else if ((c[i] - 1) % fac == 0 || (c[i] + 1) % fac == 0)
      L[i] = L[i - 1] + b;
    ans = min(ans, L[i] + (n - i) * a);
  }
  R[n + 1] = 0;
  for (int i = n; i >= 1; i--) {
    R[i] = inf;
    if (c[i] % fac == 0)
      R[i] = R[i + 1];
    else if ((c[i] - 1) % fac == 0 || (c[i] + 1) % fac == 0)
      R[i] = R[i + 1] + b;
  }
  for (int i = 1; i <= n; i++) L[i] -= i * a;
  for (int i = 1; i <= n; i++) R[i] += (i - 1) * a;
  long long mn = 0;
  for (int i = 1; i <= n; i++) {
    ans = min(ans, R[i] + mn);
    mn = min(mn, L[i]);
  }
  return ans;
}
int main() {
  int n;
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 1; i <= n; i++) scanf("%d", c + i);
  f(c[1]);
  f(c[n]);
  sort(d.begin(), d.end());
  d.erase(unique(d.begin(), d.end()), d.end());
  for (int i = 0; i < d.size(); i++) ans = min(ans, sol(d[i], n));
  printf("%I64d\n", ans);
  return 0;
}
