#include <bits/stdc++.h>
using namespace std;
long long ans = 1LL * 1000000007 * 1000000007;
vector<long long> arr;
long long a, b;
int n;
long long dp[1000001][3];
void CLR() {
  for (int i = 0; i <= n; i++) dp[i][0] = dp[i][1] = dp[i][2] = (long long)1E16;
}
set<int> primes;
void F(int val) {
  for (int i = 2; 1LL * i * i <= val; i++) {
    if (val % i == 0) {
      primes.insert(i);
      while (val % i == 0) val /= i;
    }
  }
  if (val > 1) primes.insert(val);
}
void solve(int gcd) {
  CLR();
  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[0][2] = 0;
  for (int i = 0; i < (int)arr.size(); i++) {
    long long costForEle = (long long)1E16;
    int f = arr[i] % gcd;
    if (f == (gcd - 1) or f == 1)
      costForEle = b;
    else if (!f)
      costForEle = 0;
    for (int j = 0; j < 3; j++) {
      if (j == 2) {
        dp[i + 1][2] = min(dp[i + 1][2], dp[i][2] + costForEle);
      } else if (j == 1) {
        dp[i + 1][2] = min(dp[i + 1][2], dp[i][1] + a);
        dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a);
        dp[i][2] = min(dp[i][2], dp[i][1]);
      } else {
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + costForEle);
        dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + a);
        dp[i][1] = min(dp[i][1], dp[i][0]);
      }
    }
  }
  ans = min(ans, dp[n][2]);
  ans = min(ans, dp[n][0]);
  ans = min(ans, dp[n][1]);
}
int main() {
  cin >> n >> a >> b;
  arr.resize(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = -1; i <= 1; i++) {
    F(arr[0] + i);
    F(arr[n - 1] + i);
  }
  for (set<int>::iterator ii = primes.begin(); ii != primes.end(); ii++)
    solve(*ii);
  cout << ans << "\n";
  return 0;
}
