#include <bits/stdc++.h>
using namespace std;
int A[1000000 + 2];
vector<int> get_prime(int x) {
  vector<int> p;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      p.push_back(i);
      while (x % i == 0) {
        x /= i;
      }
    }
  }
  if (x > 1) p.push_back(x);
  return p;
}
long long DP[1000000 + 2][3];
int main() {
  ios_base::sync_with_stdio(0);
  int n, a, b;
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  vector<int> v;
  vector<int> pr;
  for (int i = -1; i <= 1; i++) {
    pr = get_prime(A[0] + i);
    for (int j = 0; j < (int)pr.size(); j++) v.push_back(pr[j]);
    pr = get_prime(A[n - 1] + i);
    for (int j = 0; j < (int)pr.size(); j++) v.push_back(pr[j]);
  }
  long long res = LLONG_MAX;
  for (int i = 0; i < (int)v.size(); i++) {
    memset(DP, 0, sizeof(DP));
    for (int j = 1; j <= n; j++) {
      for (int k = 0; k < 3; k++) {
        long long ans = 1e15;
        if (k == 0) {
          if (A[j - 1] % v[i] == 0) ans = min(ans, DP[j - 1][0]);
          if (((A[j - 1] + 1) % v[i] == 0) || ((A[j - 1] - 1) % v[i] == 0)) {
            ans = min(ans, DP[j - 1][0] + b);
          }
          ans = min(ans, DP[j - 1][2] + a);
          ans = min(ans, DP[j - 1][1] + a);
        } else if (k == 1) {
          if (A[j - 1] % v[i] == 0) ans = min(ans, DP[j - 1][2]);
          if (((A[j - 1] + 1) % v[i] == 0) || ((A[j - 1] - 1) % v[i] == 0)) {
            ans = min(ans, DP[j - 1][2] + b);
          }
          ans = min(ans, DP[j - 1][1] + a);
          ans = min(ans, DP[j - 1][2] + a);
        } else {
          if (A[j - 1] % v[i] == 0) ans = min(ans, DP[j - 1][2]);
          if (((A[j - 1] + 1) % v[i] == 0) || ((A[j - 1] - 1) % v[i] == 0)) {
            ans = min(ans, DP[j - 1][2] + b);
          }
        }
        DP[j][k] = ans;
      }
    }
    res = min(res, DP[n][0]);
    res = min(res, DP[n][1]);
    res = min(res, DP[n][2]);
  }
  cout << res << endl;
}
