#include <bits/stdc++.h>
using namespace std;
int n, a, b, arr[1000006 + 10];
long long dp[1000006][3], ans = (1ll << 60);
void solve(int p) {
  dp[0][0] = arr[0] % p == 0 ? 0 : b;
  dp[0][1] = (1ll << 60);
  dp[0][2] = dp[0][0];
  for (int i = 1; i < n; i++) {
    dp[i][0] = dp[i][1] = dp[i][2] = (1ll << 60);
    for (int j = -1; j <= 1; j++) {
      if ((arr[i] + j) % p == 0) {
        if (j == 0) {
          dp[i][0] = min(dp[i][0], dp[i - 1][0]);
          dp[i][2] = min(dp[i][2], min(dp[i - 1][2], dp[i - 1][1]));
        } else {
          dp[i][0] = min(dp[i][0], dp[i - 1][0] + b);
          dp[i][2] = min(dp[i][2], min(dp[i - 1][2] + b, dp[i - 1][1] + b));
        }
      }
    }
    dp[i][1] = min(dp[i][1], min(dp[i - 1][0] + a, dp[i - 1][1] + a));
  }
  ans = min(ans, min(dp[n - 1][0], min(dp[n - 1][1], dp[n - 1][2])));
}
int main() {
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) cin >> arr[i];
  set<int> st;
  for (int i = -1; i <= 1; i++) {
    int num = arr[0] + i;
    for (int j = 2; j * j <= num; j++) {
      if (num % j == 0) {
        st.insert(j);
        while (num % j == 0) num /= j;
      }
    }
    if (num > 1) st.insert(num);
  }
  set<int>::iterator it;
  for (it = st.begin(); it != st.end(); it++) solve(*it);
  reverse(arr, arr + n);
  st.clear();
  for (int i = -1; i <= 1; i++) {
    int num = arr[0] + i;
    for (int j = 2; j * j <= num; j++) {
      if (num % j == 0) {
        st.insert(j);
        while (num % j == 0) num /= j;
      }
    }
    if (num > 1) st.insert(num);
  }
  for (it = st.begin(); it != st.end(); it++) solve(*it);
  cout << ans;
  return 0;
}
