#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const long long INF = 1e18;
long long dp[N][3];
long long val[N];
long long a, b;
int n;
vector<long long> gcd;
void init(long long x) {
  for (long long 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);
}
long long solve(long long g) {
  long long temp;
  dp[0][0] = dp[0][1] = dp[0][2] = 0;
  for (int i = 1; i <= n; i++) {
    temp = 1e18;
    if ((val[i] + 1) % g == 0 || (val[i] - 1) % g == 0) temp = b;
    if (val[i] % g == 0) temp = 0;
    dp[i][0] = dp[i - 1][0] + temp;
    dp[i][0] = min(dp[i][0], INF);
    dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]) + temp;
    dp[i][2] = min(dp[i][2], INF);
    dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + a;
    dp[i][1] = min(dp[i][1], INF);
  }
  return min(dp[n][0], min(dp[n][1], dp[n][2]));
}
int main() {
  scanf("%d%I64d%I64d", &n, &a, &b);
  for (int i = 1; i <= n; i++) scanf("%I64d", &val[i]);
  gcd.clear();
  init(val[1]);
  init(val[1] + 1);
  init(val[1] - 1);
  init(val[n]);
  init(val[n] + 1);
  init(val[n] - 1);
  sort(gcd.begin(), gcd.end());
  gcd.erase(unique(gcd.begin(), gcd.end()), gcd.end());
  long long ans = 2e18;
  for (int i = 0; i < gcd.size(); i++) {
    ans = min(solve(gcd[i]), ans);
  }
  printf("%I64d\n", ans);
  return 0;
}
