#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int const N = 1000 * 1000 + 16;
int const M = 1000 * 1000 * 1000 + 7;
int n, a, b;
int v[N];
ll chk(int prime) {
  vector<vector<ll>> dp(3, vector<ll>(n + 1));
  dp[0][0] = 0;
  dp[1][0] = 0;
  dp[2][0] = 0;
  ll inf = 1e16;
  auto cost = [inf](int x, int p) {
    if (x % p == 0)
      return 0ll;
    else if ((x + 1) % p && (x - 1) % p)
      return inf;
    else
      return (ll)b;
  };
  for (int i = 1; i <= n; ++i) {
    int z = v[i - 1];
    dp[0][i] = dp[0][i - 1] + cost(z, prime);
    dp[1][i] = min(dp[0][i - 1], dp[1][i - 1]) + a;
    dp[2][i] = min(dp[1][i - 1], dp[2][i - 1]) + cost(z, prime);
    dp[0][i] = min(dp[0][i], inf);
    dp[1][i] = min(dp[1][i], inf);
    dp[2][i] = min(dp[2][i], inf);
  }
  return min(dp[0][n], min(dp[1][n], dp[2][n]));
}
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  cin >> n >> a >> b;
  for (int i = 0; i < n; ++i) cin >> v[i];
  vector<int> p;
  for (int x :
       {v[0] - 1, v[0], v[0] + 1, v[n - 1] - 1, v[n - 1], v[n - 1] + 1}) {
    for (int i = 2; i * i <= x; ++i) {
      if (x % i) continue;
      while (x % i == 0) x /= i;
      p.emplace_back(i);
    }
    if (x > 1) p.emplace_back(x);
  }
  sort(p.begin(), p.end());
  p.erase(unique(p.begin(), p.end()), p.end());
  ll ans = 1e16;
  for (int x : p) ans = min(ans, chk(x));
  cout << ans << endl;
}
