#include <bits/stdc++.h>
int dr[] = {2, 2, -2, -2, 1, -1, 1, -1};
int dc[] = {1, -1, 1, -1, 2, 2, -2, -2};
int dr1[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dc1[] = {1, -1, 1, 0, -1, 0, 1, -1};
int dr2[] = {0, 0, 1, -1};
int dc2[] = {1, -1, 0, 0};
using namespace std;
long long int mark[32000];
vector<long long int> v, pr;
long long int a[1000005], b1, b2, n;
long long int dp[1000002][3];
void sieve() {
  long long int i, j;
  for (i = 3; i < 32000; i += 2) {
    if (mark[i] == 0) {
      for (j = i + i; j < 32000; j += i) mark[j] = 1;
    }
  }
  v.push_back(2);
  for (i = 3; i < 32000; i += 2)
    if (mark[i] == 0) v.push_back(i);
}
long long int k;
void factor(long long int n) {
  long long int i;
  for (i = 0; i < v.size() && v[i] <= sqrt(n); i++) {
    if (n % v[i] == 0) {
      while (n % v[i] == 0) n /= v[i];
      pr.push_back(v[i]);
    }
  }
  if (n != 1) pr.push_back(n);
}
long long int query(long long int k) {
  long long int i;
  dp[1][0] = 0;
  bool f = 0;
  long long int p = a[1] % k;
  if (p != 0) dp[1][0] = b2;
  dp[1][1] = dp[1][0];
  for (i = 2; i <= n; i++) {
    long long int p = a[i] % k;
    if (p > 1 && p < k - 1) f = 1;
    dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + b1;
    dp[i][0] = dp[i - 1][0];
    if (p == 1 || p == k - 1) dp[i][0] = dp[i - 1][0] + b2;
    if (f == 1) dp[i][0] = 10000000000000000;
  }
  long long int s = 0;
  long long int ans = min(dp[n][0], dp[n][1]);
  for (i = n; i >= 1; i--) {
    long long int p = a[i] % k;
    if (p > 1 && p < k - 1) break;
    if (p == 1 || p == k - 1) s += b2;
    long long int r = min(dp[i - 1][0], dp[i - 1][1]) + s;
    ans = min(r, ans);
  }
  return ans;
}
long long int query1() {
  factor(a[1] + 1);
  factor(a[1]);
  factor(a[1] - 1);
  sort(pr.begin(), pr.end());
  long long int ans = 10000000000000000;
  long long int pre = -1, i;
  for (i = 0; i < pr.size(); i++) {
    if (pre == pr[i]) continue;
    k = pr[i];
    pre = k;
    ans = min(ans, query(k));
  }
  return ans;
}
int main() {
  long long int i;
  sieve();
  cin >> n >> b1 >> b2;
  for (i = 1; i < n + 1; i++) cin >> a[i];
  long long int ans = b1 * n;
  ans = min(ans, query1());
  pr.clear();
  reverse(a + 1, a + n + 1);
  ans = min(ans, query1());
  cout << ans << endl;
}
