#include <bits/stdc++.h>
using namespace std;
const long long NMAX = 1e6 + 10;
const long long INF = 1e18;
long long n, a, b;
long long v[1 + NMAX];
long long dp[1 + NMAX][3];
long long res;
long long cnt, pr;
long long compute() {
  for (long long i = n; i >= 0; i--) {
    for (long long j = 0; j <= 2; j++) {
      dp[i][j] = INF;
      if (v[i] % pr == 0) {
        if (j == 1)
          dp[i][j] = dp[i + 1][2];
        else
          dp[i][j] = dp[i + 1][j];
      }
      if (j != 2) dp[i][j] = min(dp[i][j], dp[i + 1][1] + a);
      if ((v[i] - 1) % pr == 0 || (v[i] + 1) % pr == 0) {
        if (j == 1)
          dp[i][j] = min(dp[i][j], dp[i + 1][2] + b);
        else
          dp[i][j] = min(dp[i][j], dp[i + 1][j] + b);
      }
    }
  }
  return dp[0][0];
}
long long solve(long long x) {
  long long res = INF;
  long long aux = x;
  for (long long i = 2; i * i <= aux; i++) {
    if (x <= 1) break;
    if (x % i == 0) {
      cnt++;
      pr = i;
      res = min(res, compute());
      while (x % i == 0) x /= i;
    }
  }
  if (x != 1) {
    cnt++;
    pr = x;
    res = min(res, compute());
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> a >> b;
  for (long long i = 1; i <= n; i++) cin >> v[i];
  res = INF;
  for (long long z = -1; z < 2; z++) {
    res = min(res, solve(v[1] + z));
    res = min(res, solve(v[n] + z));
  }
  cout << res << '\n';
  return 0;
}
