#include <bits/stdc++.h>
using namespace std;
long long n, A, B, a[1000010];
long long pri[100010], ispri[100010], cnt = 0;
void get() {
  for (long long i = 2; i <= 100000; i++) {
    if (!ispri[i]) pri[++cnt] = i;
    for (long long j = 1; j <= cnt; j++) {
      if (i * pri[j] > 100000) break;
      ispri[i * pri[j]] = true;
      if (i % pri[j] == 0) break;
    }
  }
}
long long dp[1000010][3];
vector<long long> vec;
void GET(long long x) {
  for (long long i = 1; i <= cnt; i++) {
    if (x % pri[i] == 0) {
      vec.push_back(pri[i]);
      while (x % pri[i] == 0) {
        x /= pri[i];
      }
    }
  }
  if (x != 1) {
    vec.push_back(x);
  }
}
long long fans;
int main() {
  scanf("%lld%lld%lld", &n, &A, &B);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  get();
  GET(a[1]);
  GET(a[n]);
  GET(a[1] + 1);
  GET(a[1] - 1);
  GET(a[n] + 1);
  GET(a[n] - 1);
  sort(vec.begin(), vec.end());
  fans = 1e18;
  for (long long ii = 0; ii < vec.size(); ii++) {
    if (ii > 0 && vec[ii] == vec[ii - 1]) continue;
    long long x = vec[ii];
    memset(dp, 0, sizeof(dp));
    for (long long i = 1; i <= n; i++) {
      if (a[i] % x == 0) {
        dp[i][0] = dp[i - 1][0];
        dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + A;
        dp[i][2] = min(dp[i - 1][2], dp[i - 1][1]);
      } else if ((a[i] + 1) % x == 0 || (a[i] - 1) % x == 0) {
        dp[i][0] = dp[i - 1][0] + B;
        dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + A;
        dp[i][2] = min(dp[i - 1][2], dp[i - 1][1]) + B;
      } else {
        dp[i][0] = 1e18;
        dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + A;
        dp[i][2] = 1e18;
      }
    }
    fans = min(fans, min(min(dp[n][0], dp[n][1]), dp[n][2]));
  }
  printf("%lld\n", fans);
  return 0;
}
