#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
long long inf = 1000000000000000ll;
vector<int> prime;
const int maxn = 2000000;
int a[maxn], b[maxn];
long long A, B;
long long dp[maxn][3];
int n;
inline void suck(int k) {
  for (int i = 2; i * i <= k; i++)
    if (k % i == 0) {
      prime.push_back(i);
      while (k % i == 0) k /= i;
      if (k == 1) return;
    }
  if (k != 1) prime.push_back(k);
}
inline long long gao(int p) {
  vector<pair<int, int> > range;
  int st = 0, en = 0;
  int last_one = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] % p == 0)
      b[i] = 1;
    else if ((a[i] + 1) % p == 0)
      b[i] = 2;
    else if ((a[i] - 1) % p == 0)
      b[i] = 2;
    else
      b[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 2; j++) dp[i][j] = inf;
    if (b[i] == 1) {
      dp[i][0] = dp[i - 1][0];
      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]);
    } else if (b[i] == 2) {
      dp[i][0] = dp[i - 1][0] + B;
      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]) + B;
    } else {
      dp[i][0] = inf;
      dp[i][1] = min(dp[i - 1][1], dp[i - 1][0]) + A;
      dp[i][2] = inf;
    }
  }
  long long ret = inf;
  for (int j = 0; j <= 2; j++) ret = min(ret, dp[n][j]);
  return ret;
}
int main() {
  cin >> n >> A >> B;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  suck(a[1] - 1);
  suck(a[1]);
  suck(a[1] + 1);
  suck(a[n] - 1);
  suck(a[n]);
  suck(a[n] + 1);
  long long ans = inf;
  sort(prime.begin(), prime.end());
  prime.erase(unique(prime.begin(), prime.end()), prime.end());
  for (int i = 0; i < prime.size(); i++) ans = min(ans, gao(prime[i]));
  cout << ans << endl;
}
