#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int INF = 1e9 + 100;
const LL INF64 = INF * 1LL * INF;
vector<int> factorize(int x) {
  vector<int> fact;
  for (int i = 2; i * 1LL * i <= x; ++i) {
    if (x % i == 0) {
      fact.push_back(i);
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) {
    fact.push_back(x);
  }
  return fact;
}
int is_good(int x, int pr) {
  return x % pr == 0 || (x + 1) % pr == 0 || (x - 1) % pr == 0;
}
int cost(int x, int pr) {
  if (x % pr == 0)
    return 0;
  else if ((x + 1) % pr == 0 || (x - 1) % pr == 0)
    return 1;
  else
    return INF;
}
LL check(vector<int> &ar, int pr, LL a, LL b) {
  vector<vector<LL>> dp(2, vector<LL>(3, INF64));
  dp[0][0] = 0;
  for (int i = 0; i < ar.size(); ++i) {
    for (int j = 0; j < 3; ++j) {
      if (j == 0) {
        dp[!(i & 1)][0] =
            min(dp[!(i & 1)][0], dp[i & 1][0] + cost(ar[i], pr) * b);
      }
      if (j == 1 || j == 0) {
        dp[!(i & 1)][1] = min(dp[!(i & 1)][1], dp[i & 1][j] + a);
        dp[!(i & 1)][2] = min(dp[!(i & 1)][2], dp[i & 1][j] + a);
      }
      if (j == 2) {
        dp[!(i & 1)][2] =
            min(dp[!(i & 1)][2], dp[i & 1][j] + cost(ar[i], pr) * b);
      }
    }
    dp[i & 1][0] = dp[i & 1][1] = dp[i & 1][2] = INF64;
  }
  return min(dp[ar.size() & 1][0], dp[ar.size() & 1][2]);
}
void solve() {
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> ar(n);
  for (auto &it : ar) cin >> it;
  set<int> factors;
  auto v = factorize(ar.front());
  factors.insert(v.begin(), v.end());
  v = factorize(ar.front() + 1);
  factors.insert(v.begin(), v.end());
  v = factorize(ar.front() - 1);
  factors.insert(v.begin(), v.end());
  v = factorize(ar.back());
  factors.insert(v.begin(), v.end());
  v = factorize(ar.back() + 1);
  factors.insert(v.begin(), v.end());
  v = factorize(ar.back() - 1);
  factors.insert(v.begin(), v.end());
  LL ans = INF * 1LL * INF;
  for (auto pr : factors) {
    ans = min(ans, check(ar, pr, a, b));
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  solve();
}
