#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const long long INF = 1e10;
long long dp[maxn][3] = {0};
long long n, a, b, ans = 1e18;
long long sv[maxn] = {0}, cost[maxn] = {0};
vector<long long> gcd;
void cal(long long x) {
  long long i;
  for (i = 1; i <= n; i++) {
    cost[i] = INF;
    if (sv[i] % x == 0) {
      cost[i] = 0;
    } else if (((sv[i] + 1) % x == 0 && (sv[i] + 1)) ||
               ((sv[i] - 1) % x == 0 && (sv[i] - 1))) {
      cost[i] = b;
    }
  }
  for (i = 1; i <= n; i++) {
    dp[i][0] = dp[i - 1][0] + cost[i];
    dp[i][1] = min(dp[i - 1][1], dp[i - 1][0]) + a;
    dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]) + cost[i];
  }
  ans = min(min(min(dp[n][0], dp[n][1]), dp[n][2]), ans);
}
void pre(long long x) {
  long long i;
  for (i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      gcd.push_back(i);
    }
    while (x % i == 0) {
      x /= i;
    }
  }
  if (x != 1) {
    gcd.push_back(x);
  }
}
int main() {
  int i, l;
  scanf("%I64d%I64d%I64d", &n, &a, &b);
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &sv[i]);
  }
  pre(sv[1]), pre(sv[1] - 1), pre(sv[1] + 1);
  pre(sv[n]), pre(sv[n] - 1), pre(sv[n] + 1);
  sort(gcd.begin(), gcd.end());
  gcd.erase(unique(gcd.begin(), gcd.end()), gcd.end());
  l = gcd.size();
  for (i = 0; i < l; i++) {
    cal(gcd[i]);
  }
  cout << ans << endl;
}
