#include <bits/stdc++.h>
using namespace std;
long long dp[1000005][3];
int A[1000005];
const long long INF = numeric_limits<long long>::max() / 3;
long long n, a, b;
int P;
long long getdp(int x, int y) {
  if (dp[x][y] != -1) return dp[x][y];
  if (x == n) return dp[x][y] = 0;
  long long best = INF;
  if (A[x] % P <= 1 || A[x] % P == P - 1)
    best = min(best, getdp(x + 1, y == 0 ? 0 : 2) + (A[x] % P == 0 ? 0 : b));
  if (y <= 1) best = min(best, a + getdp(x + 1, 1));
  return dp[x][y] = best;
}
long long go(int p) {
  if (p <= 1) return INF;
  fill(&dp[0][0], &dp[0][0] + sizeof(dp) / sizeof(dp[0][0]), -1);
  P = p;
  return getdp(1, 0);
}
long long factor_and_go(int v) {
  long long best = INF;
  if (v % 2 == 0) {
    best = go(2);
    while (v % 2 == 0) v /= 2;
  }
  for (int i = 3; i * i <= v; i += 2) {
    if (v % i == 0) {
      best = min(best, go(i));
      while (v % i == 0) v /= i;
    }
  }
  return min(best, go(v));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) cin >> A[i];
  long long best = INF;
  for (int t = 0; t < 2; t++) {
    for (int tt = -1; tt <= 1; tt++) {
      const int v = A[0] + tt;
      const int c = b * (tt != 0);
      best = min(best, c + factor_and_go(v));
    }
    if (t == 0) reverse(A, A + n);
  }
  cout << best << endl;
  return 0;
}
