#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const long long INF = 1e+18;
int A[1000000];
int n, a, b;
set<int> primes;
void generatePrimes(int num) {
  for (int i = 2; i * i <= num; i++) {
    if (num % i == 0) {
      primes.insert(i);
      while (num % i == 0) num /= i;
    }
  }
  if (num > 1) primes.insert(num);
}
long long solve(int prime) {
  long long** dp = new long long*[n];
  for (int i = 0; i < n; i++) {
    dp[i] = new long long[3];
  }
  dp[0][0] =
      (A[0] % prime == 0
           ? 0
           : (((A[0] + 1) % prime == 0 || (A[0] - 1) % prime == 0) ? b : INF));
  dp[0][1] = a;
  dp[0][2] = INF;
  for (int i = 1; i < n; i++) {
    dp[i][0] = (A[i] % prime == 0
                    ? dp[i - 1][0]
                    : (((A[i] + 1) % prime == 0 || (A[i] - 1) % prime == 0)
                           ? (dp[i - 1][0] + b)
                           : INF));
    dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + a;
    dp[i][2] =
        min(dp[i - 1][1], dp[i - 1][2]) +
        ((A[i] % prime == 0)
             ? 0
             : ((((A[i] - 1) % prime == 0 || (A[i] + 1) % prime == 0)) ? b
                                                                       : INF));
  }
  long long ans = min(dp[n - 1][0], min(dp[n - 1][1], dp[n - 1][2]));
  for (int i = 0; i < n; i++) {
    delete[] dp[i];
  }
  delete[] dp;
  return ans;
}
int main() {
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  generatePrimes(A[0]);
  generatePrimes(A[0] + 1);
  generatePrimes(A[0] - 1);
  generatePrimes(A[n - 1]);
  generatePrimes(A[n - 1] + 1);
  generatePrimes(A[n - 1] - 1);
  long long ans = INF;
  for (auto prime = primes.begin(); prime != primes.end(); prime++) {
    ans = min(ans, solve(*prime));
  }
  cout << ans;
  return 0;
}
