#include <bits/stdc++.h>
using namespace std;
const int SQN = 31630;
const int MAXN = 1e6 + 1;
vector<int> prosti_brojevi;
bool prost[SQN];
const long long inf = (long long)1e17;
long long n, A, B;
long long minV = inf;
int niz[MAXN];
long long dp[MAXN][3];
void solve() {
  for (int k = 0; k < prosti_brojevi.size(); k++) {
    long long cp = prosti_brojevi[k];
    long long delta;
    if (niz[0] % cp == 0)
      delta = 0;
    else if ((niz[0] - 1) % cp == 0 || (niz[0] + 1) % cp == 0)
      delta = B;
    else
      delta = inf;
    dp[0][0] = delta;
    dp[0][2] = dp[0][1] = A;
    for (int i = 1; i < n; i++) {
      if (niz[i] % cp == 0)
        delta = 0;
      else if ((niz[i] - 1) % cp == 0 || (niz[i] + 1) % cp == 0)
        delta = B;
      else
        delta = inf;
      dp[i][0] = dp[i - 1][0] + delta;
      dp[i][1] = min(dp[i - 1][1] + delta, dp[i - 1][2] + delta);
      dp[i][2] = min(dp[i - 1][0] + A, dp[i - 1][2] + A);
      dp[i][0] = min(dp[i][0], inf);
      dp[i][1] = min(dp[i][1], inf);
      dp[i][2] = min(dp[i][2], inf);
    }
    minV = min(minV, min(dp[n - 1][0], min(dp[n - 1][1], dp[n - 1][2])));
  }
}
set<long long> brojiproste;
void generatePrimes() {
  for (int i = 0; i < SQN; i++) prost[i] = true;
  prost[0] = prost[1] = false;
  for (int i = 2; i < SQN; i++) {
    if (!prost[i]) continue;
    for (int j = i * 2; j < SQN; j += i) prost[j] = false;
  }
  long long mogucnosti[] = {niz[0],     niz[0] + 1,     niz[0] - 1,
                            niz[n - 1], niz[n - 1] + 1, niz[n - 1] - 1};
  for (int i = 0; i < 6; i++) {
    for (int j = 2; j < SQN; j++) {
      if (!prost[j]) continue;
      if (mogucnosti[i] % j == 0) brojiproste.insert(j);
      while (mogucnosti[i] % j == 0) {
        mogucnosti[i] /= j;
      }
    }
    if (mogucnosti[i] > 1) brojiproste.insert(mogucnosti[i]);
  }
  for (set<long long>::iterator iter = brojiproste.begin();
       iter != brojiproste.end(); iter++) {
    prosti_brojevi.push_back(*iter);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> A >> B;
  for (int i = 0; i < n; i++) cin >> niz[i];
  generatePrimes();
  solve();
  cout << minV << endl;
  return 0;
}
