#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3", "omit-frame-pointer", "inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
using namespace std;
const long long mod = 1000000007;
mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
const int mxN = 1000010;
int n;
vector<int> pr;
long long a, b;
vector<long long> v;
long long INF = 1000000000000010ll;
void add_pr(long long x) {
  for (long long i = 2; i * i <= x; i++)
    if (x % i == 0) {
      pr.push_back(i);
      while (x % i == 0) x /= i;
    }
  if (x > 1) pr.push_back(x);
}
long long dp[3][3];
long long cost(long long p) {
  dp[0][0] = dp[0][1] = dp[0][2] = 0;
  for (int i = 1; i <= n; i++) {
    int d = i & 1;
    int idx = i - 1;
    int o = d ^ 1;
    if (v[idx] % p == 0) {
      dp[d][0] = dp[o][0];
      dp[d][1] = min(dp[o][0], dp[o][1]) + a;
      dp[d][2] = min(dp[o][2], dp[o][1]);
    } else if (((v[idx] + 1) % p == 0) || ((v[idx] - 1) % p == 0)) {
      dp[d][0] = dp[o][0] + b;
      dp[d][1] = min(dp[o][0], dp[o][1]) + a;
      dp[d][2] = min(dp[o][2], dp[o][1]) + b;
    } else {
      dp[d][0] = INF;
      dp[d][1] = min(dp[o][0], dp[o][1]) + a;
      dp[d][2] = INF;
    }
    dp[o][0] = dp[o][1] = dp[o][2] = INF;
  }
  int s = n & 1;
  return min(dp[s][0], min(dp[s][1], dp[s][2]));
}
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(time(NULL));
  cout << fixed << setprecision(9);
  int t = 1, C = 1;
  while (t--) {
    cin >> n >> a >> b;
    v.resize(n);
    pr.clear();
    for (int i = 0; i < n; i++) cin >> v[i];
    {
      for (int f = -1; f < 2; f++) add_pr(v[0] + f), add_pr(v[n - 1] + f);
      sort(pr.begin(), pr.end());
      pr.erase(unique(pr.begin(), pr.end()), pr.end());
    }
    long long res = n * a;
    for (auto p : pr) {
      res = min(res, cost(p));
    }
    cout << res << '\n';
  }
  return 0;
}
