#include <bits/stdc++.h>
using namespace std;
const int N = 1000007;
const int M = 22;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int n, A, B;
vector<int> ns;
vector<int> primes;
long long dp[N][M];
void get_primes(int num, set<int>& st) {
  if (num <= 1) {
    return;
  }
  if (num % 2 == 0) {
    st.insert(2);
    num /= 2;
  }
  for (long long i = 3; i * i <= num; i += 2) {
    if (num % i == 0) {
      st.insert(i);
    }
    while (num % i == 0) {
      num /= i;
    }
  }
  if (num != 1) {
    st.insert(num);
  }
}
long long solve() {
  memset(dp, INF, sizeof(dp));
  long long ans = INF;
  for (int i = 0; i < primes.size(); i++) {
    long long delta = 1LL * A * n;
    for (int j = 0; j < n; j++) {
      long long mincost = INF;
      for (int k = -1; k <= 1; k++) {
        int u = ns[j] + k;
        long long cost = 1LL * abs(k) * B - A;
        if (u % primes[i] == 0) {
          mincost = min(mincost, cost);
        }
      }
      if (mincost == INF) {
        break;
      }
      delta += mincost;
      dp[j][i] = delta;
      ans = min(ans, delta);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < primes.size(); j++) {
      if (i - 1 >= 0) {
        dp[i][j] = min(dp[i][j], dp[i - 1][j]);
      }
    }
  }
  for (int i = 0; i < primes.size(); i++) {
    long long delta = 0;
    for (int j = n - 1; j >= 0; j--) {
      long long mincost = INF;
      for (int k = -1; k <= 1; k++) {
        int u = ns[j] + k;
        long long cost = 1LL * abs(k) * B - A;
        if (u % primes[i] == 0) {
          mincost = min(mincost, cost);
        }
      }
      if (mincost == INF) {
        break;
      }
      delta += mincost;
      if (j - 1 >= 0) {
        ans = min(ans, delta + dp[j - 1][i]);
      }
    }
  }
  return ans;
}
int main() {
  cin >> n >> A >> B;
  ns.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &ns[i]);
  }
  set<int> st;
  get_primes(ns[0], st);
  get_primes(ns[n - 1], st);
  get_primes(ns[0] - 1, st);
  get_primes(ns[n - 1] - 1, st);
  get_primes(ns[0] + 1, st);
  get_primes(ns[n - 1] + 1, st);
  primes.reserve(st.size());
  for (auto num : st) {
    primes.push_back(num);
  }
  long long ans = INF;
  ans = min(ans, solve());
  reverse(ns.begin(), ns.end());
  ans = min(ans, solve());
  cout << ans << endl;
  return 0;
}
